]
In the image, we have a table and we are supposed to use PIVOT functions in SQL to obtain the exact output shown below the original table. I have tried it but not able to get it. Can someone please help!!
]
In the image, we have a table and we are supposed to use PIVOT functions in SQL to obtain the exact output shown below the original table. I have tried it but not able to get it. Can someone please help!!
You can use conditional aggregation:
select name,
max(case when grade = 1 then marks end) as grade1,
max(case when grade = 2 then marks end) as grade2,
max(case when grade = 3 then marks end) as grade3
from mytable
group by name