Answer the question
In order to leave comments, you need to log in
How to sort null down in GROUP BY?
There is a query
SELECT name, DATE_FORMAT(date, '%Y - %m'), AVG(grade)
FROM `student`
LEFT JOIN `grade` ON student.id = grade.student_id
GROUP BY student.name, DATE_FORMAT(date, ' %Y - %m')
ORDER BY name, DATE_FORMAT(date, '%Y - %m')
outputs like this
Vasya 2018 - 04 4.5
Vasya 2018 - 05 5
Zhanna NULL NULL
Kolya 2018 - 05 4.5
Marina 2018 - 05 1.5
Masha NULL NULL
Petya 2018 - 05 4.5
how to do like this
Vasya 2018 - 04 4.5
Vasya 2018 - 05 5
Kolya 2018 - 05 4.5
Marina 2018 - 05 1.5
Petya 2018 - 05 4.5
Zhanna NULL NULL
Masha NULL NULL
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question