Using SQL Select Query with the table of following structure
Id Name Subject
07 anu Maths
07 anu English
07 anu Hindi
I want the Result as
Id Name Sub1 Sub2 Sub3
07 Anu Maths English Hindi
Using SQL Select Query with the table of following structure
Id Name Subject
07 anu Maths
07 anu English
07 anu Hindi
I want the Result as
Id Name Sub1 Sub2 Sub3
07 Anu Maths English Hindi
Try this it will help you
SELECT Name,
MAX(CASE WHEN Subject = 'Maths' THEN Subject ELSE NULL END) [subject1],
MAX(CASE WHEN Subject = 'English' THEN Subject ELSE NULL END) [subject2],
MAX(CASE WHEN Subject = 'Hindi' THEN Subject ELSE NULL END) [subject3]
FROM Subject
GROUP BY Name
;)