标签:order by group by nbsp http and acl name months src
列出在每个部门工作的员工数量、平均工资和平均工作月数
SELECT d.DNAME,t.sumPerson,t.avgSal,t.avgTime FROM DEPT d,
(SELECT DEPTNO dno, count(EMPNO) sumPerson,trunc(avg(sal)) avgSal,trunc(avg(months_between(sysdate,HIREDATE))) avgTime
FROM EMP GROUP BY DEPTNO) t WHERE t.dno(+)=d.DEPTNO ORDER BY 1
列出所有部门的详细信息和部门人数。
SELECT d.DEPTNO,d.dname,d.LOC,t.count FROM DEPT d,
(SELECT count(EMPNO) count,DEPTNO dno FROM EMP GROUP BY DEPTNO) t
WHERE t.dno=d.DEPTNO
列出各种工作的最低工资及从事此工作的雇员姓名
SELECT e.EMPNO,e.ENAME,e.SAL FROM EMP e,
(SELECT min(sal) min,job FROM EMP GROUP BY job) t
WHERE t.JOB=e.JOB AND e.SAL=t.min
标签:order by group by nbsp http and acl name months src
原文地址:https://www.cnblogs.com/HUCHEN/p/10017410.html