aggregate/window fonksiyonlara bakınız.

http://code.openark.org/blog/mysql/selecting-a-specific-aggregated-column-data-in-group-by

https://stackoverflow.com/questions/29243379/mysql-aggregate-function-with-group-by-and-join

kolay gele.