我在SQL中有这个查询:
select cast(faturas.datatotal as date) as Dia, faturas.sumF, credito.sumC, isnull(sumF,0)-isnull(sumC,0) as Total
from
(SELECT SUM([Line Amount]) as sumF, [Posting Date] as datatotal
FROM [CMW$Sales Invoice Line]
where [CMW$Sales Invoice Line].[Posting Date] >= '2017-01-01'
group by [CMW$Sales Invoice Line].[Posting Date]) faturas
full outer join
(SELECT SUM(Amount) as sumC, [Posting Date]
FROM [CMW$Sales Cr_Memo Line]
where [CMW$Sales Cr_Memo Line].[Posting Date] >= '2017-01-01'
group by [CMW$Sales Cr_Memo Line].[Posting Date]) credito
on faturas.datatotal=credito.[Posting Date]
我需要计算累计"总计"在同一个查询中。我怎么能得到这个?
答案 0 :(得分:0)
我用这个解决了我的问题:
sum(isnull(sumF,0)-isnull(sumC,0)) over(order by faturas.datatotal rows unbounded preceding) as Acumulado
由于