解答
182
SQL文(クエリ)
SELECT prefecture , SUM(p) AS premium_users , COUNT(DISTINCT user_id) AS users , SUM(p) / COUNT(DISTINCT user_id) AS premium_rate FROM ( SELECT prefecture , user_id , IF(is_premium IS TRUE, 1, 0) AS p FROM sample.customers ) GROUP BY prefecture ORDER BY 2 DESC LIMIT 3