Many thanks, the exercises have been interesting and useful!
So I tried to recreate the results for Exercise 185 Activation rate per country but without using the mobile_analytics.events
table.
The results can’t be replicated due to differences in tables i.e. number of unique users in mobile_analytics.events table: 2508 number of unique iphone users in devices table: 4223
But is the logic of my query attempt correct?
WITH mob_readers_and_users AS (
SELECT
country,
COUNT(DISTINCT CASE WHEN last_page > 0 THEN d.user_id END) AS reader_num,
COUNT(DISTINCT d.user_id) AS user_num
FROM users u
LEFT JOIN books_users b
ON u.id = b.user_id
LEFT JOIN devices d
ON u.id = d.user_id
WHERE
device_type = 'iphone'
GROUP BY 1
)
SELECT
country,
reader_num,
ROUND(100.0 * reader_num / user_num, 2) AS activation_rate
FROM mob_readers_and_users
ORDER BY 3 DESC