Hi @Sri Kotte ,
Please try:
CREATE TABLE #test(div_id int,primo int,md int,curve_name varchar(25),curve_value decimal(3,1))
INSERT INTO #test VALUES(10,1234,12,'rop',45.6),
(10,1234,13,'rop',43.5),
(10,1234,14,'rop',40.6),
(10,1234,12,'hook_load',11.2),
(10,1234,13,'hook_load',12.3)
SELECT *
FROM (SELECT div_id,primo,md,curve_name,curve_value
FROM #test
WHERE primo = 1234
AND curve_name IN ('ROP',
'HOOK_LOAD')
) t
PIVOT (MAX (curve_value)
FOR curve_name
IN (ROP,HOOK_LOAD)) p
Output:
For more details, please refer to::
FROM - Using PIVOT and UNPIVOT
If you have any question, please feel free to let me know.
If the response is helpful, please click "Accept Answer" and upvote it.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.