question

aarju avatar image
aarju asked

SQL Running Total Query

I have 4 rows

                    
open_qty, deptin_qty, deptout_qty ,clsg_qty                    
10        0           0              0                    
0         5           0              0                    
0         0           -20            0                    
0         10          0              0                    

this way i want result

                    
open_qty, deptin_qty, deptout_qty ,clsg_qty                    
10         0           0              10                    
10         5           0              15                    
15         0           -20            -5                    
-5         10          0              5                    

how to do using update query plz help me

sql-server-2008sql-server-2005ssisselect
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Madhivanan avatar image
Madhivanan answered

One of the methods is the one shown under running total here

http://sqlblogcasts.com/blogs/madhivanan/archive/2009/06/10/quirky-update-in-sql-server.aspx

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rajib Bahar avatar image
Rajib Bahar answered

are you asking how to use the UPDATE query?

Madhivanan pointed you to a good article.

Here is another link to help you research more.

http://doc.ddart.net/mssql/sql70/ua-uz_3.htm

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.