How can I generate a series of repeating numbers in PostgreSQL?

后端 未结 7 808
长发绾君心
长发绾君心 2021-01-17 07:36

In PostgreSQL, is it possible to generate a series of repeating numbers? For example, I want to generate the numbers 1 to 10, with each number repeated 3 times:



        
相关标签:
7条回答
  • 2021-01-17 08:30
    SELECT * FROM (SELECT generate_series(1, 10)) A
    JOIN (
      SELECT generate_series(1, 3)
    ) B ON (TRUE)
    

    http://www.sqlfiddle.com/#!12/d41d8

    0 讨论(0)
提交回复
热议问题