问问题
52 次
3 回答
2
您可以使用相关子查询
select * from tablename t1 where salary =
(select max(salary) from tablename t2 where t1.deptname=t2.deptname)
于 2018-10-23T10:05:26.370 回答
1
如果支持您的 dbms,请使用窗口功能
select * from
(
select *, row_number() over(partition by department order sal desc) rn
from your_tab
) t where t.rn=1
于 2018-10-23T10:11:49.920 回答
0
select sal.empid,sal.name,t.department,t.sal from salary ,(select department,MAX(sal) as sal from salary group by dep)t
where sal.dep=t.dep and sal.sal=t.sal
于 2018-10-23T10:42:02.147 回答