Skip to content
Advertisement

SQL/Presto: how to rank within a subgroup of each group

I have a table like the following:

i want to rank user_id within subgroup of each group by the score and then by time (earlier better) each user_id gets. so the desired output is

Advertisement

Answer

Use rank():

Actually, I’m not sure if higher scores are better than lower ones, so you might want score asc.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement