解答

175

SQL文(クエリ)

WITH master AS (
  SELECT
    order_id
    , SUM(revenue) AS sum_rev
  FROM
    sample.sales
  GROUP BY
    order_id
)
SELECT
  order_id
  , sum_rev
  , sum_rev / (
    SELECT
      MAX(sum_rev)
    FROM
      master
  ) AS percentage_against_max_revenue
FROM
  master
ORDER BY
  sum_rev DESC
LIMIT 5

結果テーブル

結果テーブル

サポートページに戻る