select a.dep,a.name
from emp a join
     (  select dep,max(sal) as m
        from emp
        group by dep
     ) b 
     on a.dep=b.dep and a.sal=b.m

解决方案 »

  1.   

    Select dep,nqme,job,Max(sal) As sal From MEP Group by dep,nqme,job
      

  2.   

    select name from EMP
    where sal in(
                   select max(sal) from EMP
                     group by dep)
      

  3.   

    select * from EMP a where sal=(select max(sal) from EMP b where a.dep=b.dep
    and a.job=b.job and a.nqme=b.nqme) z
      

  4.   

    select a.*
    from emp a join(select dep,sal=max(sal) from emp)b on a.dep=b.dep and a.sal=b.sal
      

  5.   

    select a.dept, a.job from emp a where a.sal > (select avg(sal) from emp)
      

  6.   

    不好意思,小的还有一个问题。
    列出工资在900以上,或者姓氏在‘que'和'aur' 之间的,这样写可以吗?
    select name.emp from emp where sal>=900 or name between 'que' and 'zur'
      

  7.   

    TO: viptiger(六嘎)
    你的语句不严谨。(你会查出工资在本部门不是最高,但是与其他某个部门的最高工资相同的员工)
    TO:apple00000(小子) 可以
      

  8.   

    TO:xhh_88(三友)
    那那个语句应该怎么写呢,是要查出所有部门工资最高的员工.
      

  9.   

    victorycyz(中海) , zjcxc(邹建) ( ) 这两位不上对的吗?
      

  10.   

    TO:xhh_88(三友)
    jion和group by 分别是什么意思
    不好意思,比较菜
      

  11.   

    jion --联合或合并group by --分组统计---你还是看帮助比较好些!