我喜欢的聚合子查询来解决求每组前N名的方式:
select a.user_name, b.timestr, b.kills
from user1 as a inner join user_kills as b
on a.user_id = b.user_id
where (select count(c.user_id) from user_kills as c where c.kills > b.kills) < 2;
select a.user_name, b.timestr, b.kills
from user1 as a inner join user_kills as b
on a.user_id = b.user_id
where (select count(c.user_id) from user_kills as c where c.kills > b.kills) < 2;
2016-10-23
求每个分组中的前N条记录在LeetCode中的数据库题目中已经是难度为Hard级别了,可以参考我的博客实现:http://blog.csdn.net/wzy_1988/article/details/52871636
2016-10-23