SQL to generate a list of numbers from 1 to 100

后端 未结 11 1467
悲&欢浪女
悲&欢浪女 2020-11-27 04:07

Using the DUAL table, how can I get a list of numbers from 1 to 100?

11条回答
  •  有刺的猬
    2020-11-27 04:28

    If you want your integers to be bound between two integers (i.e. start with something other than 1), you can use something like this:

    with bnd as (select 4 lo, 9 hi from dual)
    select (select lo from bnd) - 1 + level r
    from dual
    connect by level <= (select hi-lo from bnd);
    

    It gives:

    4
    5
    6
    7
    8
    

提交回复
热议问题