I have a table with 23 total rows. One of the columns is called thing
. There are only 11 distinct things out of the 23 total rows.
When I run:
SELECT DISTINCT thing FROM tablename WHERE condition
I correctly get 11 rows.
However, when I run:
SELECT DISTINCT COUNT(thing) FROM tablename WHERE condition
I get 23 for the total count. However, I want to get 11, which is the count of the distinct things. How can I rewrite my query so that it gives me a total count of 11?
CodePudding user response:
SELECT COUNT(DISTINCT thing) FROM tablename WHERE condition