解答

129

SQL文(クエリ)

WITH master AS (
  SELECT
    user_id
    , SUM(revenue) AS sum_rev
  FROM
    sample.sales
  GROUP BY
    user_id
)
SELECT
  prefecture
  , sum_rev
FROM
  master
  LEFT JOIN sample.customers
  USING
    (user_id)
ORDER BY
  sum_rev DESC
LIMIT 1

結果テーブル

結果テーブル

サポートページに戻る