mysql每日一题- 部分top3工资查询

image

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 )

posted on 2021-09-17 14:40  多一点  阅读(152)  评论(0编辑  收藏  举报

导航