您的位置:首页 > 其它

分段函数,列转行

2015-08-19 06:12 357 查看
SELECT

sum(CASE when score<60 then 1 else 0 end) AS '不及格',

sum(CASE when score>=60 and score<70 then 1 else 0 end) AS '差',

sum(CASE when score>=70 and score<80 then 1 else 0 end) AS '中',

sum(CASE when score>=80 and score<90 then 1 else 0 end) AS '良',

sum(CASE when score>=90 and score<=100 then 1 else 0 end) AS '优'

from student;
http://my.oschina.net/repine/blog/295961
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: