解答

218

SQL文(クエリ)

WITH master AS (
  SELECT
    FORMAT_DATETIME("%Y-%m", date_time) AS year_month
    , SUM(revenue) AS sum_rev
  FROM
    sample.sales
  WHERE
    FORMAT_DATETIME("%Y", date_time) = "2017"
  GROUP BY
    year_month
)
SELECT
  year_month
  , ROUND(sum_rev / FIRST_VALUE(sum_rev) OVER (ORDER BY year_month), 2) 
  AS change_from_jan
FROM
  master
ORDER BY
  2 DESC
LIMIT 3

結果テーブル

結果テーブル

サポートページに戻る