请用SQL语句统计职员薪资水平,且分为五个档次(1000以下,1000(含)-2000(不含),2000-3000,3000-4000

2025-03-05 12:45:33
推荐回答(4个)
回答1:

你是要统计每个部门各档次薪资的人数吗?

你可以用类似如下的语句来实现,其中sm_dep为你的部门表名。

select a.deptid,b.deptname,
count(case when salary < 1000 then 1 end) as 1000以下,
count(case when salary >= 1000 and salary < 2000 then 1 end) as 1000(含)-2000(不含),
count(case when salary >= 2000 and salary < 3000 then 1 end) as 2000(含)-3000(不含),
count(case when salary >= 3000 and salary < 4000 then 1 end) as 3000(含)-4000(不含)
from sm_employee a,sm_dep b
where a.deptid = b.deptid
group by a.deptid,b.deptname

回答2:

SELECT (FLOOR (salary / 1000) + 1) * 1000, COUNT (*)
FROM TB
GROUP BY (FLOOR (salary / 1000) + 1) * 1000
ORDER BY (FLOOR (salary / 1000) + 1) * 1000;

回答3:

oracle数据库?

回答4:

你需要是查询语句,给什么数据库结构,把表中的信息列出来 不要表结构