I have a table that defines objects with a given number of iterations, let's say it's a game with a variable number of rounds.
# select * from game;
game_id | num_rounds
--------+-----------
A | 2
B | 3
C | 1
I'd like to create a select statement that will generate a table with one row per round for every game.
# select ???;
game_id | round_number
--------+-------------
A | 1
A | 2
B | 1
B | 2
B | 3
C | 1
No need for a subquery and a join in
generate_series()
. A lateral join is simpler, and more efficient: