解答

173

SQL文(クエリ)

SELECT
  prefecture
  , SUM(revenue) AS sum_rev
  , SUM(revenue) / (
    SELECT
      SUM(revenue)
    FROM
      sample.sales
  ) AS percent_sum_rev
FROM
  sample.sales
  LEFT JOIN sample.customers
  USING
    (user_id)
GROUP BY
  prefecture
ORDER BY
  sum_rev DESC
LIMIT 3

結果テーブル

結果テーブル

サポートページに戻る