Skip to content

Instantly share code, notes, and snippets.

@cloverink
Created July 8, 2022 17:20
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 cloverink/4b4d160bdd48540178abd652138e6c7a to your computer and use it in GitHub Desktop.
Save cloverink/4b4d160bdd48540178abd652138e6c7a to your computer and use it in GitHub Desktop.
How to Group by Time in PostgreSQL
select
date_trunc('minute', created_at), -- or hour, day, week, month, year
count(1)
from users
group by 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment