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