下午,开发的说出一个需求,要求说显示ename,job,和job这个岗位的人数
下面是语句:
select e.ename,e.job,a.c renshu
from emp e,(select job,count(job) c from emp group by job) a
where e.job=a.job
SQL> /
ENAME JOB RENSHU
---------- --------- ----------
MILLER CLERK 4
JAMES CLERK 4
ADAMS CLERK 4
SMITH CLERK 4
TURNER SALESMAN 4
MARTIN SALESMAN 4
WARD SALESMAN 4
ALLEN SALESMAN 4
KING PRESIDENT 1
CLARK MANAGER 3
BLAKE MANAGER 3
ENAME JOB RENSHU
---------- --------- ----------
JONES MANAGER 3
FORD ANALYST 2
SCOTT ANALYST 2
下面是语句:
select e.ename,e.job,a.c renshu
from emp e,(select job,count(job) c from emp group by job) a
where e.job=a.job
SQL> /
ENAME JOB RENSHU
---------- --------- ----------
MILLER CLERK 4
JAMES CLERK 4
ADAMS CLERK 4
SMITH CLERK 4
TURNER SALESMAN 4
MARTIN SALESMAN 4
WARD SALESMAN 4
ALLEN SALESMAN 4
KING PRESIDENT 1
CLARK MANAGER 3
BLAKE MANAGER 3
ENAME JOB RENSHU
---------- --------- ----------
JONES MANAGER 3
FORD ANALYST 2
SCOTT ANALYST 2
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31098809/viewspace-2082003/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31098809/viewspace-2082003/