Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created May 17, 2024 21:39
Show Gist options
  • Save PaulieScanlon/0c0ec37a102eef9e38fc9d4bfd33d83f to your computer and use it in GitHub Desktop.
Save PaulieScanlon/0c0ec37a102eef9e38fc9d4bfd33d83f to your computer and use it in GitHub Desktop.
Happy Reactions Production SQL query
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