Last active
March 18, 2023 11:57
-
-
Save rubengmurray/5d1d76e3b791c29ceba1b2acbe7e6fbc to your computer and use it in GitHub Desktop.
This file contains 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
-- COUNT ITEMS BY DATE INTERVAL | |
SELECT | |
DATE_TRUNC('hour', my_date_field), -- or second, minute, hour, day, week, month, year | |
COUNT(id) | |
FROM my_table | |
WHERE my_field IS NOT NULL | |
GROUP BY 1 | |
ORDER BY 2 DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment