Skip to content

Instantly share code, notes, and snippets.

@datwright
Created September 6, 2011 15:54
Show Gist options
  • Save datwright/1197953 to your computer and use it in GitHub Desktop.
Save datwright/1197953 to your computer and use it in GitHub Desktop.
pass_fail
SELECT u.id, u.name, COUNT(CASE WHEN `assessment_results`.passed = 1 THEN 1 ELSE NULL END) / COUNT(*) as pass_rate, COUNT(*) as total, COUNT(CASE WHEN `assessment_results`.passed = 1 THEN 1 ELSE NULL END) FROM users u
LEFT JOIN assessment_results ON assessment_results.user_id = u.id
WHERE u.certification_id = 3
AND (u.certification_status = 'green' OR u.certification_status = 'yellow')
AND assessment_results.submitted = true
group by u.id
ORDER BY pass_rate DESC a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment