/** The core solution is to generate a column from 1 to 10 as the "secondary column "**/Select level l FROM dual connect by level <= 10;[Problem]Two tables A B
Table:
Id pid
A1 1
A2 2
A3 3
Table B:
Pid pnumber
1 2
2 3
3 5
Generate such information based on the number of pnumbers
Id list
A1 A1-1
A1 A1-2
A2 A1-1
A2 A1-2
A2 A1-3
A3 A1-1
A3 A1-2
A3 A1-3
A3 A1-4
A3 A1-5/** create A test table T1 that the landlord said A table **/Create table t1 (ID VARCHAR2 (10 ),Pid VARCHAR2 (10));/** Create the test table T2, that is, the B Table mentioned by the author **/Create table t2 (Pid VARCHAR2 (10 ),Pnumber VARCHAR2 (10));/** Insert T1 data and T2 test data **/Insert into t1 VALUES ('a1', '1 ');Insert into t1 VALUES ('a2 ', '2 ');Insert into t1 VALUES ('a3 ', '3 ');Insert into t2 VALUES ('1', '2 ');Insert into t2 VALUES ('2', '3 ');Insert into t2 VALUES ('3', '5 ');
/** The core solution is to generate a column from 1 to 10 as the "secondary column "**/Select level l FROM dual connect by level <= 10;
/** Final SQL **/SELECT T1.ID, 'a1-'| T3.DZ AS LISTFROM T1, T2, (select level dz from dual connect by level <= 10) T3WHERE T1.PID = T2.PIDAND T3.DZ <= T2.PNUMBEROrder by 1, 2;