How to write a query to get cumulative spending?

Question

Assume you are given a table for spending activity by product type which has column names as order_id, user_id, product_id, spend, date . How to write a query to calculate the cumulative spend for each product over time in chronological order.

in progress 1
Anonymous 3 years 2 Answers 1019 views 0

Answers ( 2 )

  1. select product_id, sum(spend) over (partition by product_id, user_id order by product_id) as Comm_Spend from table;

  2. Ꮋello i am kavin, its my first time to commenting anyplace, when i read this post i thought i
    could also make comment due to this good post.

Leave an answer

Browse
Browse