查询各个部门工资范围,按照1000~2000,2000~3000.。。。这样的格式显示人数
select * from (select job,count(*) as "1000~2000" from
(select sal,job from emp
where sal<=2000 and sal>=1000)
group by job) a
full join
(select job,count(*) as "2000~3000" from
(select sal,job from emp
where sal<=3000 and sal>2000)
group by job) b
on a.job=b.job
full join (select job,count(*) as "3000~4000" from
(select sal,job from emp
where sal<=4000 and sal>3000)
group by job) c
on b.job=c.job
full join (select job,count(*) as "4000~5000" from
(select sal,job from emp
where sal<=5000 and sal>4000)
group by job) d
on d.job=c.job
时间: 2024-10-06 11:11:29