Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

multiple count with where clause sql

SELECT distributor_id,
    count(*) AS total,
    sum(case when level = 'exec' then 1 else 0 end) AS ExecCount,
    sum(case when level = 'personal' then 1 else 0 end) AS PersonalCount
FROM yourtable
GROUP BY distributor_id
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #multiple #count #clause #sql
ADD COMMENT
Topic
Name
6+2 =