TSQL-Accmulations
- From: "Batool" <bhijazin@xxxxxxxxxx>
- Date: Sun, 1 Jul 2007 16:45:10 +0200
I need an appropriate select statement for my case, the case is a table with
two columns (row id ,col1) I want to retrieve a three columns
RowId, col1 ,accumulation of col1
I wrote this select statement, but the performance is going down is there an
alternative way for writing this SQL statement
SELECT RowID ,Col1, (SELECT SUM(Col1) from tablehh where RowID <=aa.RowId)
AS Col2 FROM tablehh as aa ORDER BY Col1,Col2
The output should be like this:
RowId Col1 Col2
1 10 10
2 100 110
3 15 125
4 20 145]
Col2 is the accumulation of col1
thx;
batool.
.
- Follow-Ups:
- Re: TSQL-Accmulations
- From: MG
- Re: TSQL-Accmulations
- From: JPD
- Re: TSQL-Accmulations
- Next by Date: Re: SQL Server client components - What is this?
- Next by thread: Re: TSQL-Accmulations
- Index(es):
Relevant Pages
|
Loading