解答
142
SQL文(クエリ)
WITH master AS ( SELECT user_id , SUM(revenue) AS sum_rev FROM sample.sales GROUP BY user_id ) SELECT gender , is_premium , SUM(sum_rev) AS sum_rev FROM master LEFT JOIN sample.customers USING (user_id) WHERE prefecture = "東京" GROUP BY gender , is_premium ORDER BY gender , is_premium DESC