如问题中所述,我使用以下MySQL生成排行榜。
SELECT DISTINCT t1.level, t3.user_id, t3.user_id2, t3.user_type
FROM leaderboard AS t1
INNER JOIN clear_times AS t2
ON (t1.uid = t2.uid AND (t1.level -1) = t2.level)
INNER JOIN registrations AS t3 ON (t1.uid = t3.id)
ORDER BY t1.level DESC, t2.clear_time ASC
但该声明的问题在于它仅提取level
大于1
的用户记录。没有提取级别为“1”的记录。