duplication of rows without primary key

Viewed 69

How to duplicate a row 40 times in PostgreSQL which doesn't have a primary key attached to it?

Ex:

14/11/2021
15/11/2021

Output should be:

14/11/2021
14/11/2021
14/11/2021
14/11/2021
..... 40 times
15/11/2021
15/11/2021
15/11/2021
15/11/2021
15/11/2021 
... 40 times
1 Answers

We can try doing a cross join with the help of generate_series:

SELECT t1.date
FROM yourTable t1
CROSS JOIN generate_series(1, 40)
ORDER BY t1.date;
Related