Chris Ongsuco's Weblog
Information Technology, business, life, food...

SQL Running Total

Wednesday, February 16, 2005 12:25 AM
Good for reporting...try it!

Use Northwind

SELECT
P.ProductID,
P.ProductName,
P.UnitsInStock,
(SELECT SUM(UnitsInStock) FROM Products WHERE ProductID <= P.ProductID) AS UnitsInStockRunningTotal
FROM Products P

Feedback

# re: SQL Running Total

Very nice! 7/22/2006 10:53 PM | John Peptra

Post a comment