我有一张具有每日销售价值的表格。我想每个月创建一个总计。我尝试了一个窗口函数,但它会继续添加而不是在新月开始时重新开始。
我正在使用的查询。
select
date, name, sum(sales) over (partition by name order by date)
from sales.table
Date Name Sales
2016-01-01 John 140.75
2016-01-02 John 169.20
2016-01-03 John 600.25
.... .... ....
2016-01-31 John 32731.91
2016-02-01 John 32914.81 <-- Start over for the month