SQL语句中CASE WHEN的使用实例

https://blog.csdn.net/haiross/article/details/46412581

典型应用

select 课程号,
sum(case when 成绩>=60 then 1 
     else 0 
    end) as 及格人数,
sum(case when 成绩 <  60 then 1 
     else 0 
    end) as 不及格人数
from score
group by 课程号;

猜你喜欢

转载自www.cnblogs.com/654321cc/p/12357324.html