试着写一下我的语句和理解,比老师的更加有可读性,好理解
老师给出的答案可读性实在太差了,不直观,不符合正常逻辑,老师又不作解释。下面是我的语句:
SELECT c.user_name, c.timestr, c.kills FROM
(SELECT a.id, a.user_name, b.timestr, b.kills FROM user1 a INNER JOIN user_kills b on a.id = b.user_id) c
INNER JOIN user_kills d ON c.id = d.user_id AND c.kills <= d.kills
GROUP BY c.user_name, c.timestr
HAVING COUNT(*) <= 2
ORDER BY c.user_name, c.kills DESC;