clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 921346 fiddles created (11966 in the last week).

CREATE TABLE game_logs (user_id INT, game_id INT, game_detail INT);
 hidden batch(es)


INSERT INTO game_logs (user_id, game_id, game_detail) VALUES (6,10,100), (6,11,260), (7,10,1200), (7,11,500), (7,12,260), (7,13,50);
 hidden batch(es)


SELECT *, ( SELECT COUNT(DISTINCT game_detail) + 1 FROM game_logs AS x WHERE user_id = t.user_id AND game_detail > t.game_detail ) AS user_game_rank FROM game_logs AS t ORDER BY user_id, user_game_rank
user_id game_id game_detail user_game_rank
6 11 260 1
6 10 100 2
7 10 1200 1
7 11 500 2
7 12 260 3
7 13 50 4
 hidden batch(es)