Page 1 of 1

Getting multiple dynamic counts on a single column

Posted: Fri Aug 03, 2007 2:43 pm
by printf
Is there some method to return a single row with multiple COUNTS on single column based on different values matching that column?

Posted: Fri Aug 03, 2007 3:07 pm
by Begby
Since the counts in the field clause are tied to a single where clause, you will need to do this with subqueries like

Code: Select all

SELECT
( SELECT COUNT(*) FROM tbl WHERE something=something) as myFirstCount,
( SELECT COUNT(*) FROM tbl WHERE something=somethingelse) as mySecondCount