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
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With