Created
July 1, 2015 06:10
-
-
Save shunjikonishi/20d78dc4a57a422a9215 to your computer and use it in GitHub Desktop.
This file contains 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 | |
c.id, | |
count(cr.id) as count | |
FROM challenges c | |
LEFT OUTER JOIN exam_challenges ec ON (c.id = ec.challenge_id) | |
INNER JOIN exams e ON (ec.exam_id = e.id) | |
LEFT OUTER JOIN exam_delivers ed ON (ed.exam_id = e.id) | |
LEFT OUTER JOIN challenge_results cr ON (c.id = cr.challenge_id AND cr.deliver_id = ed.id) | |
WHERE c.user_id in (1) | |
GROUP BY c.id | |
ORDER BY c.id desc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment