Created
May 17, 2024 21:39
-
-
Save PaulieScanlon/0c0ec37a102eef9e38fc9d4bfd33d83f to your computer and use it in GitHub Desktop.
Happy Reactions Production SQL query
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
WITH happy_reactions AS ( | |
SELECT analytics.city, analytics.country, analytics.flag, COUNT(reactions.id) AS count | |
FROM analytics | |
INNER JOIN reactions ON analytics.slug = reactions.slug | |
WHERE reactions.reaction = 'happy' AND analytics.date >= CURRENT_DATE - INTERVAL '30' DAY | |
GROUP BY analytics.city, analytics.country, analytics.flag | |
) | |
SELECT city, country, flag, count | |
FROM happy_reactions | |
ORDER BY count DESC | |
LIMIT 50; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment