用PLSQL语言,就是
declare
....
begin
....
end
这样的结构写出下面的题目.
[使用table:EMP]
依SAL列出各部门在各区间的人数
使用N个DECODE DEPTNO $3001-$9999 $2001-$3000 $1001-$2000 < $1000
---------- ----------- ----------- ----------- ----------
10 1 1 1 0
20 0 3 1 1
30 0 1 4 1
要求是:不能使用GROUP BY 和连接.
declare
....
begin
....
end
这样的结构写出下面的题目.
[使用table:EMP]
依SAL列出各部门在各区间的人数
使用N个DECODE DEPTNO $3001-$9999 $2001-$3000 $1001-$2000 < $1000
---------- ----------- ----------- ----------- ----------
10 1 1 1 0
20 0 3 1 1
30 0 1 4 1
要求是:不能使用GROUP BY 和连接.
(select count(*) from emp where sal>=3001 and sal<=9999) as s1,
(select count(*) from emp where sal>=2001 and sal<=3000) as s2,
(select count(*) from emp where sal>=1001 and sal<=2000) as s3,
(select count(*) from emp where sal<=1000) as s4
from emp
select deptno,
(select count(*) from emp where sal>=3001 and sal<=9999 and deptno=e.deptno) as s1,
(select count(*) from emp where sal>=2001 and sal<=3000 and deptno=e.deptno) as s2,
(select count(*) from emp where sal>=1001 and sal<=2000 and deptno=e.deptno) as s3,
(select count(*) from emp where sal<=1000 and deptno=e.deptno) as s4
from emp e
select distinct deptno,
(select count(*) from emp where sal>=3001 and sal <=9999 and deptno=e.deptno) as s1,
(select count(*) from emp where sal>=2001 and sal <=3000 and deptno=e.deptno) as s2,
(select count(*) from emp where sal>=1001 and sal <=2000 and deptno=e.deptno) as s3,
(select count(*) from emp where sal <=1000 and deptno=e.deptno) as s4
from emp e