polkadot (7/31/2012)
---QUERY that returns cumulative total by DayCountSELECT a.DayCount,
a.Sales,
SUM(b.Sales)
FROM Sales a
CROSS JOIN Sales b
WHERE (b.DayCount <= a.DayCount) --AS RunningTotal
GROUP BY a.DayCount,a.Sales
ORDER BY a.DayCount,a.Sales
Be very careful there. What you've got is a triangular join, which is going to cost a lot in terms of performance. Have a look at this article --> http://www.sqlservercentral.com/articles/T-SQL/61539/%5B/url%5D for more information.