B Beagle1927 Oct 25, 2007 #1 Is there anyway to produce a running total in a query? I tried the help menus but they only mention running totals in reports.
Is there anyway to produce a running total in a query? I tried the help menus but they only mention running totals in reports.
M Michel Walsh Oct 25, 2007 #2 You have to have a field that supply the order (like a dateStamp) and, sure, the value to be summed. SELECT a.dateStamp, LAST(a.theValue), SUM(b.theValue) FROM yourTable AS a INNER JOIN yourTable AS b ON a.dateStamp >= b.dateStamp GROUP BY a.dateStamp will then do. Hoping it may help, Vanderghast, Access MVP
You have to have a field that supply the order (like a dateStamp) and, sure, the value to be summed. SELECT a.dateStamp, LAST(a.theValue), SUM(b.theValue) FROM yourTable AS a INNER JOIN yourTable AS b ON a.dateStamp >= b.dateStamp GROUP BY a.dateStamp will then do. Hoping it may help, Vanderghast, Access MVP
B Beagle1927 Oct 26, 2007 #3 Hello, I cannot get it to work.... I need to calculate a running total on Total_Cost field on the TLB_Sales Table by customer. Ie. Customer A Total Cost =$125 Running total = $125 Customer B Total Cost =$100 Running total=$225 Is this possible?
Hello, I cannot get it to work.... I need to calculate a running total on Total_Cost field on the TLB_Sales Table by customer. Ie. Customer A Total Cost =$125 Running total = $125 Customer B Total Cost =$100 Running total=$225 Is this possible?
M Michel Walsh Oct 26, 2007 #4 Replace the dateStamp by the field with the customer. In Northwind, that works fine: SELECT a.ProductName, Last(a.UnitPrice), Sum(b.UnitPrice) FROM Products AS a INNER JOIN Products AS b ON a.ProductName >= b.ProductName GROUP BY a.ProductName; Vanderghast, Access MVP
Replace the dateStamp by the field with the customer. In Northwind, that works fine: SELECT a.ProductName, Last(a.UnitPrice), Sum(b.UnitPrice) FROM Products AS a INNER JOIN Products AS b ON a.ProductName >= b.ProductName GROUP BY a.ProductName; Vanderghast, Access MVP