本帖最后由 taotai110 于 2011-12-14 16:42:29 编辑

解决方案 »

  1.   

    这个别名的e是什么意思啊?
    外层emp的表的别名啊(select * from emp e );怎么理解它是本部门的?
    后面不是有deptno= e.deptno(select avg(sal) from emp where deptno= e.deptno)
      

  2.   

    有分外层emp表和内层emp表的?内容不一样的?不都是emp的内容吗?
      

  3.   

    select * from emp e where sal>(select avg(sal) from emp where deptno=你的部门号) and deptno=你的部门号;应该这样写吧,你那个语句应该是查出每个部门里面薪酬高于平均薪酬的员工
      

  4.   

     select t.empno, t.deptno, t.sal
        from emp t
       where t.sal >
             (select avg(tt.sal) from emp tt where tt.deptno = t.deptno)
       order by t.deptno
      

  5.   

    这个是相关查询,里面的e.deptno会和外面的deptno做比较