Below is Table A, where for each unique identifier there are three codes with some value.
ID Code Value --------------------- 11 1 x 11 2 y 11 3 z 12 1 p 12 2 q 12 3 r 13 1 l 13 2 m 13 3 n
I have a second table B with the format as shown below:
Id Code1_Val Code2_Val Code3_Val
There is only one line for each unique identifier. I want to populate this second table B from the first table A for each identifier from the first table.
For the first table A above, the second table B should look like:
Id Code1_Val Code2_Val Code3_Val --------------------------------------------- 11 xyz 12 pqr 13 lmn
How can I achieve this in a single SQL query?
source share