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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running totals within group

Status
Not open for further replies.

SaturnSeven

Programmer
Aug 4, 2005
40
GB
I am struggling with the following query

I have a table looking like the following
Product Qty Date
ABC 10 01-Feb-06
ABC 5 10-Feb-06
ABC 15 20-Feb-06
DEF 2 5-Feb-06
DEF 5 15-Feb-06
DEF 5 20-Feb-06

I am trying to create a query to show
Product RunningTotal Date
ABC 10 01-Feb-06
ABC 15 10-Feb-06
ABC 30 20-Feb-06
DEF 2 5-Feb-06
DEF 7 15-Feb-06
DEF 12 20-Feb-06

Can anyone help or point me in the right direction
Any help with be greatly appreciated
 
Perhaps something like this:
[tt]SELECT tblTable.Product, tblTable.[Date], (SELECT Sum(Qty) From tblTable A Where A.Product=tblTable.Product and A.[Date]<=tblTable.[Date]) AS RTot
FROM tblTable;[/tt]
 
Do a search in this forum for running total

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top