标签:
1.sccot.emp表中
查询公司的人数,以及在80,81,82,87年,每年雇用的人数,结果类似下面的格式
TOTAL 1980 1981 1982 1987
---------- ---------- ---------- ---------- ----------
14 1 10 1 2
SQL> edit
已写入 file afiedt.buf
1 select count(*) total,sum(decode(to_char(hiredate,‘YYYY‘),1980,1,0))as "1980",
2 sum(decode(to_char(hiredate,‘YYYY‘),1981,1,0))as "1981",
3 sum(decode(to_char(hiredate,‘YYYY‘),1982,1,0))as "1982",
4 sum(decode(to_char(hiredate,‘YYYY‘),1987,1,0))as "1987"
5* from emp
SQL> /
TOTAL 1980 1981 1982 1987
---------- ---------- ---------- ---------- ----------
14 1 10 1 2
标签:
原文地址:http://www.cnblogs.com/wuchao18395441006/p/4740468.html