sql case when then ...虚心求教

问题描述:

sql case when then ...虚心求教
select
case salary
when 5000 then '高薪'
when 4500 then '中薪'
when 3500 then '中低薪'
else 'null'
end as '工资等级'
from telenolist
我想统计各个工资级别的人数 那个count(*)应该放在语句的哪里,还用再填写别的语句吗?.
1个回答 分类:综合 2014-10-11

问题解答:

我来补答
select
count(*) as cnt,
case salary
when 5000 then '高薪'
when 4500 then '中薪'
when 3500 then '中低薪'
else 'null'
end as '工资等级'

from telenolist
group by case salary
when 5000 then '高薪'
when 4500 then '中薪'
when 3500 then '中低薪'
else 'null'
end
 
 
展开全文阅读
剩余:2000