How to get multiple counts with one SQL query?
Posted
by
Crobzilla
on Stack Overflow
See other posts from Stack Overflow
or by Crobzilla
Published on 2012-10-08T21:00:05Z
Indexed on
2012/10/08
21:37 UTC
Read the original article
Hit count: 190
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'
© Stack Overflow or respective owner