![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |