Skip to content

Instantly share code, notes, and snippets.

@cadecairos
Created July 19, 2016 19:56
Show Gist options
  • Save cadecairos/2957273602a2f2f9df9bef16daad9c86 to your computer and use it in GitHub Desktop.
Save cadecairos/2957273602a2f2f9df9bef16daad9c86 to your computer and use it in GitHub Desktop.
Badge stats queries
SELECT
CAST(badge.validated_on AS DATE) AS day,
COUNT(*) AS 'Badges Issued'
FROM
badge
GROUP BY year(day), month(day), day(day);
SELECT
CAST(badge.validated_on AS DATE) AS month,
COUNT(*) AS 'Badges Issued'
FROM
badge
GROUP BY year(month), month(month);
SELECT
CAST(badge.validated_on AS DATE) AS week,
COUNT(*) AS 'Badges Issued'
FROM
badge
GROUP BY week(week);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment