数据库三个工资段各段人数

MatrixRevolutions 2015-08-12 06:22:49
题目:
查询工资(sal)<2000,2000-4000,sal >4000的三个工资段 ------每个工资段的人数!

要求一条SQL语句!
...全文
148 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zbdzjx 2015-08-13
  • 打赏
  • 举报
回复
select sum(case when sal<2000 then 1 else 0 end) xy2000,
         sum(case when sal>=2000 and sal<=4000 then 1 else 0 end) y2000_4000,
         sum(case when sal>4000 then 1 else 0 end) dy4000
  from yourTable;
mayanzs 2015-08-13
  • 打赏
  • 举报
回复
select count(case when sal<2000 then 1 else null end) xy2000, count(case when sal>=2000 and sal<4000 then 1 else null end y2000_4000, count(case when sal>4000 then 1 else null end) dy4000 from yourTable;
mayanzs 2015-08-13
  • 打赏
  • 举报
回复

select count(case when sal<2000 then 1 else null end) xy2000,
         count(case when sal>=2000 and sal<4000 then 1 else null end) y2000_4000,
         count(case when sal>4000 then 1 else null end) dy4000
  from yourTable;

3,487

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧