Last active
August 29, 2015 13:56
-
-
Save tpitale/8908929 to your computer and use it in GitHub Desktop.
Group count by creation date and sum of count-to-date.
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
SELECT created_on, note_count, sum(note_count) OVER (ORDER BY created_on ASC) | |
FROM ( | |
SELECT date_trunc('day', created_at) AS created_on, count(1) AS note_count | |
FROM notes | |
GROUP BY created_on | |
ORDER BY created_on DESC | |
) AS note_counting; | |
-- WHERE created_on >= '2013-01-01' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment