Đối với mỗi giá trị value
, bạn có thể nhận được tối đa theo nhóm
:
SELECT * FROM Scores NATURAL JOIN (
SELECT player_id, value1, value2, MAX(value3) value3 FROM Scores NATURAL JOIN (
SELECT player_id, value1, MAX(value2) value2 FROM Scores NATURAL JOIN (
SELECT player_id, MAX(value1) value1 FROM Scores
GROUP BY player_id) t
GROUP BY player_id) t
GROUP BY player_id) t
ORDER BY value1 DESC, value2 DESC, value3 DESC
Xem nó trên sqlfiddle .