我有查询(如下)显示“每月”列中的数据。
但我需要将此查询重写为累积总和,如图第三列所示。我该怎么做?感谢您的回复。
我目前的查询:
select cast( ( Prodej.Ce_Jedn * Prodej.Mnoz ) / 1000 as numeric(15,2) ) as "Monthly" ,
YEAR( FAV.vatDate ) as "Rok" ,
month( FAV.VatDate ) as "Měsíc"
from Prodej
join FAKTVYDA FAV on FAV.Ci = PRODEJ.C_Fak
and FAV.Rada = PRODEJ.R_Fak
where YEAR(FAV.VATDate) > year(getdate())-3
and FAV.Rada in ('10','20','30','60')
and PRODEJ.C_Fak <> 0
and '@{Stredisko.ParameterValue}' = case Prodej.Str
when '' then FAV.Str
when '-' then FAV.Str
else Prodej.str
end
order by month(FAV.VatDate)