分段函数,列转行
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
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
相关文章推荐
- App Material Design.
- 问题点
- POJ 2965 解题报告
- 项目心得
- LeetCode Min Stack
- LeetCode Min Stack
- 关于压缩软件gzip和xz的简单对比
- First Round of Google Phone screen interview backup
- [Python爬虫] 在Windows下安装PhantomJS和CasperJS及入门介绍(上)
- Standard C++ Episode 3
- 反射
- Contain Duplicate III*******
- Standard C++ Episode 2
- Standard C++ Episode 1
- hdu 4292 Food【拆点网络流】
- zoj 3706 Break Standard Weight(dp)
- JSP时间格式的控制、显示
- servlet/过滤器/拦截器/监听器
- mybatis与oracle配置
- mybatis与mysql配置