你是要统计每个部门各档次薪资的人数吗?
你可以用类似如下的语句来实现,其中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
SELECT (FLOOR (salary / 1000) + 1) * 1000, COUNT (*)
FROM TB
GROUP BY (FLOOR (salary / 1000) + 1) * 1000
ORDER BY (FLOOR (salary / 1000) + 1) * 1000;
oracle数据库?
你需要是查询语句,给什么数据库结构,把表中的信息列出来 不要表结构