1
lichao 2013-06-04 14:06:58 +08:00
select branch_name,
sum(case level when 1 then 1 else 0 end), sum(case level when 2 then 1 else 0 end), sum(case level when 1 then 1 else 0 end) + sum(case level when 2 then 1 else 0 end) group by branch_name |
2
lichao 2013-06-04 14:08:42 +08:00 1
select branch_name,
sum(case level when 1 then score else 0 end), sum(case level when 1 then 1 else 0 end), sum(case level when 2 then score else 0 end), sum(case level when 2 then 1 else 0 end), sum(case level when 1 then score else 0 end) + sum(case level when 2 then score else 0 end), sum(case level when 1 then 1 else 0 end) + sum(case level when 2 then 1 else 0 end) group by branch_name |
4
zl8723 OP select branch_name,
sum(case level when 1 then final_score else 0 end) z_s, count(case level when 1 then final_score else null end) z_c, sum(case level when 2 then final_score else 0 end) f_s, count(case level when 2 then final_score else null end) f_c, sum( final_score) t_s, count(final_score) t_c from temp group by branch_name |