Skip to content

Instantly share code, notes, and snippets.

@jmcguirk
Created December 16, 2014 23:08
Show Gist options
  • Save jmcguirk/bdcb9a83b20b20d2db13 to your computer and use it in GitHub Desktop.
Save jmcguirk/bdcb9a83b20b20d2db13 to your computer and use it in GitHub Desktop.
7D ARPU by country/device
SELECT install.os,
install.country,
Count(DISTINCT install.device_tag) AS installs,
Count(DISTINCT economy.device_tag) AS spenders,
Sum(economy.spend_amount) AS total_spent
FROM install
LEFT OUTER JOIN economy
ON ( install.device_tag = economy.device_tag
AND economy.spend_type = 'cash_purchase'
AND Datediff('day', economy.ingest_datetime,
install.ingest_datetime) <= 7 )
WHERE install.device_tag != 'missing'
AND install.ingest_datetime < '2014-12-08'
AND install.ingest_datetime >= '2014-12-07'
GROUP BY 1,
2
ORDER BY 1 DESC,
2 DESC
LIMIT 1000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment