Home > Blockchain >  List number into TABLE records by the value in another table
List number into TABLE records by the value in another table

Time:07-13

Sorry for a little bit confuse on the title.

I would like to use SQL for join sequence table as below

Original Table Records

3
3
4
1

Result Table

1
2
3
1
2
3
1
2
3
4
1

CodePudding user response:

Based on comment you posted,

sample data:

SQL> with test (col) as
  2    (select 3 from dual union all
  3     select 3 from dual union all
  4     select 4 from dual union all
  5     select 1 from dual
  6    )

Query begins here:

  7  select column_value
  8  from test cross join
  9    table(cast(multiset(select level from dual
 10                        connect by level <= col
 11                       ) as sys.odcinumberlist));

COLUMN_VALUE
------------
           1
           2
           3
           1
           2
           3
           1
           2
           3
           4
           1

11 rows selected.

SQL>
  • Related