Skip to content

Instantly share code, notes, and snippets.

@AnIrishDuck
Created November 18, 2019 19:56
Show Gist options
  • Save AnIrishDuck/5cd9445c3664b290ee85e2064470be3f to your computer and use it in GitHub Desktop.
Save AnIrishDuck/5cd9445c3664b290ee85e2064470be3f to your computer and use it in GitHub Desktop.
SELECT date_trunc('month', date(q.created_at)) AS month, COUNT(DISTINCT r.artifact_id) AS with_outcomes, COUNT(DISTINCT q.id) AS total FROM quizzes q
LEFT OUTER JOIN learning_outcome_results r ON (r.g_shard_id = q.g_shard_id AND r.artifact_id = q.id AND r.artifact_type = 'Quizzes::QuizSubmission')
WHERE date(q.created_at) > date('2017-07-01')
GROUP BY date_trunc('month', date(q.created_at))
SELECT date_trunc('month', date(ra.created_at)) AS month, SUM(IF(regexp_like(ra.data, 'learning_outcome_id:\s+\d'), 1, 0)) AS with_outcomes, COUNT(ra.id) AS total
FROM rubric_assessments ra
WHERE date(ra.created_at) > date('2017-07-01')
GROUP BY date_trunc('month', date(ra.created_at))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment