Skip to content

Instantly share code, notes, and snippets.

@ogiovannyoliveira
Created August 6, 2020 18:42
Show Gist options
  • Save ogiovannyoliveira/855c98525816183fcfacd1fc64850aec to your computer and use it in GitHub Desktop.
Save ogiovannyoliveira/855c98525816183fcfacd1fc64850aec to your computer and use it in GitHub Desktop.
Searching and grouping datas per date, and formatting the date to day/month.
SELECT
count(*) as total,
TO_CHAR(the_date_here, 'DD/MM') as create_at
FROM
tabela
WHERE
the_date_here::date > CURRENT_DATE - 7
GROUP BY create_at
ORDER BY create_at ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment