mysql每日一题- 部分top3工资查询
solution
SELECT
a.employee,
a.department,
a.Salary
FROM
(
SELECT
*,
DENSE_RANK() over ( PARTITION BY department ORDER BY Salary DESC ) rk
FROM
( SELECT a.NAMES employee, b.NAME department, Salary FROM T0917 a INNER JOIN t0917b b ON a.DepartmentID = b.id ) a
) a
WHERE
a.rk IN ( 1, 2, 3 )