PostgreSQL join to denormalize a table with generate_series
问题 I've this table: CREATE TABLE "mytable" ( name text, count integer ); INSERT INTO mytable VALUES ('john', 4),('mark',2),('albert',3); and I would like "denormlize" the rows in this way: SELECT name FROM mytable JOIN generate_series(1,4) tmp(a) ON (a<=count) so I've a number of rows for each name equals to the count column: I've 4 rows with john, 2 with mark and 3 with albert. But i can't use the generate_series() function if I don't know the highest count (in this case 4). There is a way to