有一个员工表简况如下:
有一个薪水表salaries简况如下:
请你查找薪水排名第二多的员工编号emp_no、薪水salary、last_name以及first_name,不能使用order by完成,以上例子输出为:
工资第二多就是小于第一多
SELECT s.emp_no, s.salary, e.last_name, e.first_name FROM salaries AS s LEFT JOIN employees AS e ON s.emp_no = e.emp_no WHERE s.salary = (SELECT MAX(s2.salary) FROM salaries AS s2 WHERE s2.salary<(SELECT MAX(salary) FROM salaries));