How do I get the expected result using the SQL PIVOT function. I tried the below query to do this but I am getting only one record in the NAME column.
Sample Data:
SNO TYPE ENTRY
1 Name Andy
1 Name Kevin
1 Active Yes
1 Value 50
2 Name Andy
2 Name Julia
2 Active No
2 Value 45
Expected Result:
SNO NAME ACTIVE VALUE
1 Andy, Kevin Yes 50
2 Andy, Julia No 45
Query I tried:
select SNO,Name,Active,Value
from
(
select * from tbl1
) as PivotData
Pivot
(
max(ENTRY) for TYPE in([Name],[Active],[Value])
) as Pivoting