Groups | Blog | Home
all groups > sql server data mining > september 2003 >

sql server data mining : running sum in sql server 7.0 views


kamran
9/10/2003 2:26:36 AM
how to create running sum fiels in a sql server 7.0 view?
i have a 5000 fields and i just want each of them to have
a number starting from 1 to 5000 , i want to do this in a
Peter Kim [MS]
9/10/2003 11:04:45 AM
Forwarding to a more relevant group.
--
Peter Kim
This posting is provided "AS IS" with no warranties, and confers no rights.

[quoted text, click to view]

David Portas
9/10/2003 7:57:08 PM
"Fields"? Do you mean 5000 *rows*?

You can add a row count like this:

SELECT keycol,
(SELECT COUNT(*)
FROM Sometable
WHERE keycol<=S.keycol)
FROM Sometable AS S

Or a running sum like this:

SELECT keycol,
(SELECT SUM(amount)
FROM Sometable
WHERE keycol<=S.keycol)
FROM Sometable AS S

--
David Portas
------------
Please reply only to the newsgroup
--

[quoted text, click to view]

AddThis Social Bookmark Button