Oracle查询语句面试题(二)

2014-11-24 18:56:08 · 作者: · 浏览: 18
eptno=d.deptno group by e.deptno,d.dname;


DEPTNO DNAME COUNT(*)


------ -------------- ----------


10 ACCOUNTING 3


20 RESEARCH 5


30 SALES 6


13.查询各个部门员工工资大于平均工资(平均工资包括所有员工)的人数和员工职位(子查询)


SQL> select count(*),job from emp where sal>(select avg(sal) from emp) group by job;


14.查询工资相同的员工的工资和姓名(子查询)


SQL> select sal,ename from emp e where(select count(*) from emp where sal=e.sal group by sal)>1;



SQL> select e.sal,e.ename from emp e,emp e1 where e.sal=e1.sal and e.ename<>e1.ename;