Reputation: 5709
How to merge rows into single row in SQL?
ex: SELECT distinct studentID, studentName, MathGrade, SciGrade from vStudentGrade;
output:
StudentID studentName MathGrade SciGrade
1 Zed 89
1 Zed 98
desired output:
StudentID studentName MatheGrade SciGrade
1 Zed 89 98
Upvotes: 4
Views: 5660
Reputation: 43494
I wonder what criteria you're using to group them. I'm assuming there always be NULL values and a number... because that matches de example, but more detail would be better!
SELECT studentID, studentName, max(MathGrade), max(SciGrade) from vStudentGrade
group by studentID, studentName, MathGrade, SciGrade
Hope this helps or guide you to a solution :)
Upvotes: 3