题解 | #查找入职员工时间排名倒数第三的员工所有信息#
获得积分最多的人(一)
http://www.nowcoder.com/practice/1bfe3870034e4efeb4b4aa6711316c3b
先求和,然后排名,最后取出排名为1的
SELECT a.name,b.gsum
FROM user a,(SELECT user_id,gsum,DENSE_RANK()OVER(ORDER BY gsum DESC) AS rank
FROM(SELECT user_id,SUM(grade_num) AS gsum
FROM grade_info
GROUP BY user_id)) b
WHERE a.id = b.user_id
GROUP BY user_id
HAVING b.rank = 1;