Skip to content

Instantly share code, notes, and snippets.

@tomca32
Created June 28, 2017 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomca32/172b88629b8e2e1381e1c4acef8327fe to your computer and use it in GitHub Desktop.
Save tomca32/172b88629b8e2e1381e1c4acef8327fe to your computer and use it in GitHub Desktop.
Month-assessment query
select to_char(date_trunc('month', l.date), 'YYYY-MM') as month, count(distinct(l.id, g.student_id)) as assessments
from lessons as l
inner join grades as g
on l.id = g.lesson_id
group by month
order by month;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment