日別、商品別での価格とその累積和を取得するSQL

SELECT 
  target_date
  , shohin_id
  , price
  , SUM(price) OVER (PARTITION BY shohin_id ORDER BY target_date ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as price_sum
FROM
(
  SELECT
    target_date
    , shohin_id
    , price
  FROM
    shohin_table
)
ORDER BY 
  target_date
  , shohin_id
おすすめの記事