【SQL查询】查询列中使用条件逻辑_case when then end
2024-10-21 03:05:03
select x.范围, count(*)
from (select t.ename,
case
when t.sal <= 1000 then
'0-1000'
when t.sal <= 2000 then
'1000-2000'
when t.sal <= 3000 then
'2000-3000'
when t.sal <= 4000 then
'3000-4000'
when t.sal <= 5000 then
'3000-4000'
ELSE
'太高'
END as 范围
from emp t) x
group by x.范围
order by x.范围;
最新文章
- BZOJ1012: [JSOI2008]最大数maxnumber [线段树 | 单调栈+二分]
- codevs 3288 积木大赛
- java web学习总结(二十) -------------------监听器属性详解
- PHP热身
- PS网页设计教程XXVII——设计一个大胆和充满活力的作品集
- OpenJudge 2790 迷宫
- SpringMVC 流程 配置 接口
- udev:renamed network interface eth0 to eth1
- append与after区别
- PHP-循环结构-数组(难)
- yarn 工作原理(2)
- Mongo 开发笔记
- 51nod1237 最大公约数之和 V3
- Hdu1054 Strategic Game(最小覆盖点集)
- Invalid action class configuration that references an unknown class named [XX] .
- 关于JRebel启动tomcat访问上次工程的index.jsp
- Scrapy-从数据库取出IP并判断是否可用
- Python3中urllib使用与源代码
- (2)R中的数据类型和数据结构
- py,pyc,pyw文件的区别和使用