I tried putting in and out the student column in any way in the query but it gives error. What I want the output would be is to display the subjects into columns and will the display the computed average grade of the students for two semesters. Like this:
CodePudding user response:
Put the name of the student in the subquery
FROM
(
SELECT Student, Grades, Subject FROM Grade_Report
)AS SourceTable
SELECT Student, [English], [Mathematics], [Science], [Programming],
[History]
FROM
(
SELECT Student, Grades, Subject FROM Grade_Report
)AS SourceTable
PIVOT
(
AVG(Grades)
FOR Subject IN([English], [Mathematics], [Science], [Programming],
[History])
)AS PivotTable;