- 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
分段函数,列转行
最新推荐文章于 2021-04-13 10:48:16 发布