Sql以最高工资为员工订购

时间:2013-08-04 18:27:32

标签: sql database performance

我有一个EMPL表和SALARY表,具有通常的外键关系。如何通过最高薪水获得员工名单?我正在思考:

select e.*, s.salary 
  from EMPL e 
 inner join SALARY s on e.emp_id = s.emp_id
 order by s.salary

但是如何将max(salary)放入order by

1 个答案:

答案 0 :(得分:1)

select e.*, s.salary
from empl e
left join salary s on e.emp_id = s.emp_id
order by s.salary desc