Last active
December 14, 2016 23:16
-
-
Save dpaola2/8f067304e6d6c7c6b3f5a543a698a414 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
WITH checkpoint_completion_counts AS ( | |
SELECT | |
COUNT(checkpoint_completions.id) AS checkpoint_completions_count, | |
checkpoints.ref AS checkpoint_ref, | |
users.slug | |
FROM checkpoint_completions | |
INNER JOIN checkpoints ON checkpoint_completions.checkpoint_ref = checkpoints.ref | |
INNER JOIN users ON users.id = checkpoint_completions.user_id | |
GROUP BY 2,3 | |
) | |
SELECT | |
* | |
FROM | |
checkpoint_completion_counts | |
WHERE checkpoint_completion_counts.slug = 'user-slug' AND checkpoint_completions_count > 1 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment