schleep (3/19/2013)
How about:IF OBJECT_ID('MyTable') IS NOT NULL
DROP TABLE MyTable
GO
SELECT * INTO MyTable
FROM (VALUES(1,19), (2,90), (3,20), (4,8), (5, 9)) AS M(ID, VALUE)
GO
SELECTm.Id, SUM(m2.Value)
FROMMytable m
JOINMytablem2ON m2.ID <= m.id
GROUP BY m.Id
That will definitely work... for a while. It's what's known as a "Triangular Join". Please see the following article as to why it shouldn't be used.
http://www.sqlservercentral.com/articles/T-SQL/61539/
--Jeff Moden
Change is inevitable... Change for the better is not.