Skip to content

Instantly share code, notes, and snippets.

@lfy79001
Last active April 2, 2024 10:00
Show Gist options
  • Save lfy79001/c441969ae2630ca7edccec0a1249cc72 to your computer and use it in GitHub Desktop.
Save lfy79001/c441969ae2630ca7edccec0a1249cc72 to your computer and use it in GitHub Desktop.
WITH filtered_uniques AS (
SELECT
user_id,
COUNT(event.placement_id) AS frequency
FROM adh.cm_dt_impressions
WHERE user_id != '0'
AND event.advertiser_id IN UNNEST(@advertiser_ids)
AND event.campaign_id IN UNNEST(@campaign_ids)
AND event.country_domain_name = 'US'
GROUP BY user_id
)
SELECT
frequency,
COUNT(*) AS uniques
FROM filtered_uniques
GROUP BY frequency
ORDER BY frequency
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment