Created
December 5, 2008 17:22
-
-
Save joshuaclayton/32411 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT s.* | |
FROM scores s | |
JOIN ( | |
SELECT MAX(s1.score_value) AS score_value, s1.user_id | |
FROM scores s1 | |
JOIN companies c1 ON c1.id = s1.company_id | |
WHERE s1.company_id = 8 AND s1.status = 'validated' | |
GROUP BY s1.user_id | |
) AS high_scores ON high_scores.user_id = s.user_id AND high_scores.score_value = s.score_value | |
WHERE s.company_id = 8 AND s.status = 'validated' | |
GROUP BY s.user_id | |
ORDER BY s.score_value DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment