Is there a generic way to generate an arbitrary linear sequence in SQL?

前端 未结 6 820
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 02:37

Is there a SQL query I can do that will generate a linear sequence like

1, 2, 3, 4, 5, 6, 7 ... x+1

or

2, 7, 12, 17, 22 ...         


        
6条回答
  •  有刺的猬
    2021-01-13 02:56

    In Oracle you can do:

    select ROWNUM linear_sequence from dual CONNECT BY LEVEL <= x;
    

    where x is the end of the sequence.

提交回复
热议问题