How to get multiple counts with one SQL query?
- by Crobzilla
I am wondering how to write this query.
I know this actual syntax is bogus, but it will help you understand what I am wanting.
I need it in this format, because it is part of a much bigger query.
SELECT distributor_id,
COUNT(*) AS TOTAL,
COUNT(*) WHERE level = 'exec',
COUNT(*) WHERE level = 'personal'
I need this all returned in one query.
Also, it need to be in one row, so the following won't work:
'SELECT distributor_id, COUNT(*)
GROUP BY distributor_id'