Pergunta

I am trying something like

Select myTable.eDate, Sum(myTable.revenue) from MyTable 
GROUP BY MyTable.eDate HAVING (((MyTable.eDate) >= #1/1/2014#))

I am trying to have it basically show "Total revenue at January 1st is this, total revenue at January 2nd is this, total revenue at January 3rd is this, etc" over all dates sequentially.

A sort of "rolling cumulative sum" if that makes sense.

Note: There are eDates/revenues before January 1st in MyTable so I am also trying to restrict everything so it doesn't even look at rows before Jan 1st.

I also tried DSum but that didn't work, either.

I also tried

select
a1.eDate,
(
select Sum(a2.revenue)
FROM MyTable as a2
where
a2.eDate <= a1.eDate
) as RunningTotal
FROM MyTable as a1
Foi útil?

Solução

Im sorry but I dont have enough rep to comment.

What I think you are trying to do is a running total

SELECT (SELECT sum(revenue) from myTable a2
where a1.edate >= a2.edate)
as RunningSumField1,
edate from myTable as a1 
group by a1.edate
order by a1.edate

try this link:

MS Access 2010 Running Total in Query

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top