获取薪水第二多的员工的emp_no及其对应的薪水salary
获取当前薪水第二多的员工的emp_no以及其对应的薪水salary
https://www.nowcoder.com/practice/c1472daba75d4635b7f8540b837cc719
/*自链接,s1.salary<s2.salary 按照s1分组,s2计数有2个时,就是排名第二的薪资。 */ with t as( select s1.salary from salaries s1 join salaries s2 on s1.salary<=s2.salary group by s1.salary having count(s2.salary)=2 ) select emp_no, salary, last_name, first_name from employees left join salaries using(emp_no) where salary in (select salary from t)