Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

multiple count in sql

SELECT distributor_id,
    count(*) AS Total,
    sum(CASE WHEN inflevel = 'exec' THEN 1 ELSE 0 END) AS ExecCount,
    sum(CASE WHEN inflevel = 'personal' THEN 1 ELSE 0 END) AS PersonalCount
FROM yourtable
GROUP BY distributor_id
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #multiple #count #sql
ADD COMMENT
Topic
Name
9+9 =