Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SELECT
id
, date
, price
-- 累積金額の算出 id単位でdate順に並べ替えて、priceを累積していく
, SUM(price) OVER (PARTITION BY id ORDER BY sales_date ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as price_cumulative
FROM
dataset.table
SELECT id , date , price -- 累積金額の算出 id単位でdate順に並べ替えて、priceを累積していく , SUM(price) OVER (PARTITION BY id ORDER BY sales_date ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as price_cumulative FROM dataset.table
SELECT
    id
    , date
    , price
    -- 累積金額の算出 id単位でdate順に並べ替えて、priceを累積していく
    , SUM(price) OVER (PARTITION BY id ORDER BY sales_date ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as price_cumulative
FROM
    dataset.table
おすすめの記事