Multiple rows from a single row
Posted: Mon Jan 24, 2005 4:50 pm
Hi,
Please guide me to handle the following situation..
I have a table with the following structure.
Src Table : X
Columns : key1,key2,User_type1,UserQy1,User_type2,User_Qy2
My requirement is to split this to
Target table: Y
key1,key2,seqno,user_type1,user_qy1
key1,key2,seqno,user_type2,user_qy2
Here seqno is to avoid duplicates.it is part of composit key in target table
1. How to split into tow rows.
2. How to generate seqno. For each key1,key2 combination seqno should be like 1,2.
Infact in the original table i have 15 User_type columns each row. so i need to split into 15 (or X rows) rows with condition User_type<>' '
seqno would be 1 to 15 ( or X) for each key1,key2 combination.
Both Source and Target are DB2.
Thanks in Advance.
Please guide me to handle the following situation..
I have a table with the following structure.
Src Table : X
Columns : key1,key2,User_type1,UserQy1,User_type2,User_Qy2
My requirement is to split this to
Target table: Y
key1,key2,seqno,user_type1,user_qy1
key1,key2,seqno,user_type2,user_qy2
Here seqno is to avoid duplicates.it is part of composit key in target table
1. How to split into tow rows.
2. How to generate seqno. For each key1,key2 combination seqno should be like 1,2.
Infact in the original table i have 15 User_type columns each row. so i need to split into 15 (or X rows) rows with condition User_type<>' '
seqno would be 1 to 15 ( or X) for each key1,key2 combination.
Both Source and Target are DB2.
Thanks in Advance.