Hi,
I have table in this form SAY TABLE
upload_id col_name Value Row
13668 SS_ID 112 1
13668 AK DLP-2 1
13676 SS_ID 113 4
13676 AJ HP 4
13676 AK DSP-1 4
14576 SS_ID 142 3
14676 AI SP 3
14676 AJ Dell 3
would like to tranform this table to below table
upload_id SS_ID AK AI AJ Row
13668 112 DLP-2 -- -- 1
13676 113 DSP-2 -- HP 4
13676 142 -- SP Dell 3
right now I am using below code , but using i am not able to figure out where is the problem..
can you please suggest something
Select
tl.upload_id,
ss.value,
ak.value,
AI.value,
AJ.value,
from
TABLE tl
LEFT JOIN table ss ON tl.upload_id = ss.upload_id AND tl.col_name = 'SS_ID' AND ss.col_name = 'SS_ID' AND tl.row_id = ss.row_id
LEFT JOIN table AK ON tl.upload_id = AK.upload_id AND tl.col_name = 'SS_ID' AND AK.col_name = 'AK' AND tl.row_id = AK.row_id
LEFT JOIN table AI ON tl.upload_id = AI.upload_id AND tl.col_name = 'SS_ID' AND AI.col_name = 'AI' AND tl.row_id = AI.row_id
LEFT JOIN table AJ ON tl.upload_id = AJ.upload_id AND tl.col_name = 'SS_ID' AND AJ.col_name = 'AJ' AND tl.row_id = AJ.row_id
Thanks
I have table in this form SAY TABLE
upload_id col_name Value Row
13668 SS_ID 112 1
13668 AK DLP-2 1
13676 SS_ID 113 4
13676 AJ HP 4
13676 AK DSP-1 4
14576 SS_ID 142 3
14676 AI SP 3
14676 AJ Dell 3
would like to tranform this table to below table
upload_id SS_ID AK AI AJ Row
13668 112 DLP-2 -- -- 1
13676 113 DSP-2 -- HP 4
13676 142 -- SP Dell 3
right now I am using below code , but using i am not able to figure out where is the problem..
can you please suggest something
Select
tl.upload_id,
ss.value,
ak.value,
AI.value,
AJ.value,
from
TABLE tl
LEFT JOIN table ss ON tl.upload_id = ss.upload_id AND tl.col_name = 'SS_ID' AND ss.col_name = 'SS_ID' AND tl.row_id = ss.row_id
LEFT JOIN table AK ON tl.upload_id = AK.upload_id AND tl.col_name = 'SS_ID' AND AK.col_name = 'AK' AND tl.row_id = AK.row_id
LEFT JOIN table AI ON tl.upload_id = AI.upload_id AND tl.col_name = 'SS_ID' AND AI.col_name = 'AI' AND tl.row_id = AI.row_id
LEFT JOIN table AJ ON tl.upload_id = AJ.upload_id AND tl.col_name = 'SS_ID' AND AJ.col_name = 'AJ' AND tl.row_id = AJ.row_id
Thanks