table A 三个字段
code   start   end 
A       1       5
B       4       7
C       10      14
........
写个select 语句得到如下结果
code   number
A       1
A       2
A       3
A       4
A       5B       4
B       5
B       6
B       7C       10
C       11
C       12
C       13
C       14

解决方案 »

  1.   

    try:
    select
        A.code,(A.start+B.id) as number
    from
        A,(select 0 as id union select 1 union select 2 union ... union select 10) B
    where
        A.start+B.id<=A.end
      

  2.   

    @libin_ftsafe(子陌红尘:TS for Banking Card)谢谢如果 start 和end 跨度很大的话,还是比较麻烦的
    实际中
    最大跨度为1000
      

  3.   

    select a.code,b.n
        from a,(select rownum n from all_objects) b
        where b.n>=a.start and b.n<=a.end
      

  4.   

    select a.code,b.n
        from a,(select rownum n from all_objects) b
        where b.n>=a.start and b.n<=a.end
    -------------
    厉害,膜拜一下
      

  5.   

    如果end 的值大于>select count(*) from all_objects,上面的查询失败了