1. 程式人生 > >full join no滿連接的使用

full join no滿連接的使用

這樣的 查詢 rom full join 。。 group 部門 bsp emp


查詢各個部門工資範圍,按照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

full join no滿連接的使用