Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running total query help 2

Status
Not open for further replies.

Netherby

Programmer
Nov 9, 2001
32
GB
I have a table called tbl_Runsum with a date field called 'when' and a field with a sales figure called 'value'.

What I'm trying to do is sum the sales for each day and then look at the running total as the date progresses from the first date in the table right through to the last date.

My query is given below but when I run it I just get blanks in my running total column. Any help would be much appreciated.

SELECT tbl_RunSum.when, tbl_RunSum.when AS Adate, DSum("Value","tbl_RunSum"," [when] <= " & [Adate] & "") AS RunTot
FROM tbl_RunSum
GROUP BY tbl_RunSum.when, tbl_RunSum.when
ORDER BY tbl_RunSum.when;

Thanks
 
You may try this:
Code:
SELECT A.when, A.Value, Sum(B.Value) AS RunTot
FROM tbl_RunSum AS A INNER JOIN tbl_RunSum AS B ON A.when>=B.when
GROUP BY A.when, A.Value
ORDER BY A.when

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top