我有一张表T_A
数据形如:
col_a col_b
AAA 2
BBB 3
CCC 5
如何写一个单句SQL,得到下面的数据:
AAA 1
AAA 2
BBB 1
BBB 2
BBB 3
CCC 1
CCC 2
CCC 3
CCC 4
CCC 5
谢谢!
------解决方案--------------------
- SQL code
create table t1 (c1 varchar2(10),c2 number(5));insert into t1 values ('aaa',2);insert into t1 values ('bbb',3);insert into t1 values ('ccc',5);commit;select distinct c1,level c2from t1connect by level <= c2order by c1 c1 c2---------------------1 aaa 12 aaa 23 bbb 14 bbb 25 bbb 36 ccc 17 ccc 28 ccc 39 ccc 410 ccc 5