x

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

more ▼

asked Nov 30, 2009 at 06:25 AM in Default

avatar image

aarju
1 1 1 1

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

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

more ▼

answered Nov 30, 2009 at 09:25 AM

avatar image

Madhivanan
1.1k 3 5 9

(comments are locked)
10|1200 characters needed characters left

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

more ▼

answered Nov 30, 2009 at 10:33 AM

avatar image

Rajib Bahar
238 3 6 11

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2188
x2030
x1219
x159

asked: Nov 30, 2009 at 06:25 AM

Seen: 2104 times

Last Updated: Nov 30, 2009 at 08:46 AM

Copyright 2017 Redgate Software. Privacy Policy