multiple count in sql

Solutions on MaxInterview for multiple count in sql by the best coders in the world

showing results for - "multiple count in sql"
Antonella
28 Jan 2017
1SELECT distributor_id,
2    count(*) AS Total,
3    sum(CASE WHEN inflevel = 'exec' THEN 1 ELSE 0 END) AS ExecCount,
4    sum(CASE WHEN inflevel = 'personal' THEN 1 ELSE 0 END) AS PersonalCount
5FROM yourtable
6GROUP BY distributor_id