sql case when then ...虚心求教

[复制链接]
查看11 | 回复2 | 2011-4-13 17:48:30 | 显示全部楼层 |阅读模式
select
casesalary

when 5000then'高薪'

when 4500then'中薪'

when 3500then'中低薪'

else 'null'

end as '工资等级'


fromtelenolist
我想统计各个工资级别的人数
那个count(*)应该放在语句的哪里,还用再填写别的语句吗?。先谢谢了


回复

使用道具 举报

千问 | 2011-4-13 17:48:30 | 显示全部楼层
select count(*) as cnt,casesalary
when 5000then'高薪'
when 4500then'中薪'
when 3500then'中低薪'
else 'null'
end as '工资等级'
fromtelenolistgroup bycasesalary
when 5000then'高薪'
when 4500then'中薪'
when 3500then'中低薪'
else 'null'
回复

使用道具 举报

千问 | 2011-4-13 17:48:30 | 显示全部楼层
单独写一个查询语句:select 工资等级,count(工资等级) from table group by 工资等级
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行