Is there any way to enumerate rows of query in postgresql?
I have table like this:
Table players
id player_id game_id points
And I want query like this:
SELECT game_id, <row_number in points group>, <array of ids>
FROM players WHERE game_id = %s
GROUP BY game_id, points;
I’m not sure what you’re asking for. The “row number in points group” is a straight forward window function application but I don’t know what “array of ids” means.
Given date like this:
You can get the per-game rankings with this:
That will give you output like this: