解答
143
SQL文(クエリ)
WITH master AS ( SELECT user_id , SUM(revenue) AS sum_rev FROM sample.sales GROUP BY user_id ) SELECT IF(is_premium IS TRUE, "premium_users", "standard_users") AS user_category , MAX(sum_rev) AS max_revenue_by_customer FROM master JOIN sample.customers USING (user_id) GROUP BY user_category