0

I want to count the number of times a column value appears in my returned grouped data.

SELECT a, b, c
FROM whatever
GROUP BY a, b, c

I'm looking for a count of the distinct values with the returned data. So not rows in the database, but the new grouped table.

SELECTs within SELECTs hurt my head so please be gentle.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Peg
  • 1
  • Use that query result as source for another aggregate query. Add tag for database platform. – June7 Jan 22 '22 at 03:01
  • Does this answer your question? [Selecting COUNT(\*) with DISTINCT](https://stackoverflow.com/questions/1521605/selecting-count-with-distinct) – Chris Schaller Jan 31 '22 at 12:42
  • It helps with SQL questions that you include an example of the expected that matches your example input dataset. You will get more insightful responses if you create a _fiddle_ (search for Db Fiddle or SQL Fiddle) and post the link to it in the question. You should also tag the post with the specific database vendor (as is explained in the SQL tag wiki) – Chris Schaller Jan 31 '22 at 12:46

0 Answers0