For better understanding lets assume a table StudentMarks which contains data as
I am trying to insert data into another table StudentDetail for which i want the output to look like this
I could only think of a solution where I would make three different inserts into the StudentDetail Table based on the three different columns.
INSERT INTO StudentDetail (StudentID, Subject, Marks)
SELECT
sm.StudentID,
"Math",
sm.Math
FROM StudentMarks sm Order By sm.StudentID
INSERT INTO StudentDetail (StudentID, Subject, Marks)
SELECT
sm.StudentID,
"Science",
sm.Science
FROM StudentMarks sm Order By sm.StudentID
And similarly for English.
Please suggest any alternate or more efficient solution to solve this issue.. Thanks