Reputation: 3649
Please help me. I've been making a report where I need to count how many got the specific rate per class and how many specific class per rate. Is my desired output even possible? Please do advise me for better solutions. Thanks much.
=Desired Ouput
Used Query (Which generates wrong output)
SELECT COUNT(job_class),
job_class, finalrate
FROM t GROUP by job_clas
See my SQL FIDDLE
Upvotes: 0
Views: 27
Reputation: 49260
Use conditional aggregation.
SELECT
job_class,
sum(case when finalrate like 'A%' then 1 else 0 end) as AA,
sum(case when finalrate like 'B%' then 1 else 0 end) as B,
sum(case when finalrate like 'C%' then 1 else 0 end) as C
FROM t
GROUP by job_class
Upvotes: 2