Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 help with iteration?

Author  Topic 

tempus
Starting Member

47 Posts

Posted - 2010-06-23 : 09:59:34
hey guys,

i need an example for:

table

product_code product_quantity order_code raw_mat_code q_needed lot_no total_raw_mat_stock
a1 100 601 mp1 10 xxx3 175
b1 200 606 mp1 20 xxx1 175
c1 500 602 mp1 15 xxx6 175
d1 400 603 mp1 10 xxx9 175
e1 300 605 mp1 5 xxx4 175
f1 600 604 mp1 1 yyx4 175

what i need is another column which will be total_raw_mat_stock-q_needed as:

product_code product_quantity order_code raw_mat_code q_needed lot_no total_raw_mat_stock availb.
a1 100 601 mp1 10 xxx3 175 165
b1 200 606 mp1 20 xxx1 175 145
c1 500 602 mp1 15 xxx6 175 130
d1 400 603 mp1 10 xxx9 175 120
e1 300 605 mp1 5 xxx4 175 115
f1 600 604 mp1 1 yyx4 175 114


i dont know how to do it. i need the method of calculus. last column is the difference between stock and needed , taking into consideration the last difference. there are many codes of raw_mat_code and also of the other columns.

Thanks in advance everyone!

edit - moved to correct forum

tempus
Starting Member

47 Posts

Posted - 2010-06-23 : 10:01:47
please move to transact -SQL 2005 - sry for the mistake made!

Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2010-06-23 : 10:27:47
Search this site for "Running Total".

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -