Skip to content

Instantly share code, notes, and snippets.

@dpaola2 dpaola2/query.sql
Last active Dec 14, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.