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 课程号;

 

posted @ 2020-02-24 16:03  骑者赶路  阅读(466)  评论(0编辑  收藏  举报