要求是 如何显示高于自己部门平均工资的员工信息
表就是oracle自带的emp表 ,我写了两种方法
1.select * from emp a1 where a1.sal > (select avg(sal) from emp a2 where a2.deptno = a1.deptno);
2.select a.ename, a.sal from emp a,
(select deptno, avg(sal) mysal from emp group by deptno) temp
where a.deptno = temp.deptno and a.sal > temp.mysal;两种方法的结果都是一样的,第二种是给出的答案,我不知道第一种写法是不是对的
表就是oracle自带的emp表 ,我写了两种方法
1.select * from emp a1 where a1.sal > (select avg(sal) from emp a2 where a2.deptno = a1.deptno);
2.select a.ename, a.sal from emp a,
(select deptno, avg(sal) mysal from emp group by deptno) temp
where a.deptno = temp.deptno and a.sal > temp.mysal;两种方法的结果都是一样的,第二种是给出的答案,我不知道第一种写法是不是对的
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货