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.
| Author |
Topic |
|
boku
Starting Member
5 Posts |
Posted - 2009-11-28 : 08:08:39
|
| Hi,I have a bit of an odd one ... here is a sample of what I am dealing with...http://www.vbforums.com/attachment.php?attachmentid=74624&stc=1&d=1259384069What I need to so somehow do is add the stklevel where the code is missing to the stk level where the item code = 'DUB' based on the item number...So in the case of the sample ... for item number 01069103 ... the 24 where there is no code will be added to DUB where there is already 9 ... so DUB new stklevel will be 33I will then go through and delete the rows where the code is missing, but I can do that afterwards ...Has anyone got any tips please :)Thank you |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-11-28 : 12:07:14
|
| UPDATE sSET stklevel = s.stklevel + t.sktlevelfrom table sinner join table t ons.itemno = t.itemnowhere s.code = 'DUB' and t.code = ''JimEveryday I learn something that somebody else already knew |
 |
|
|
boku
Starting Member
5 Posts |
Posted - 2009-11-28 : 21:02:28
|
| Is this ok for the same table? Also where would I define the table, like this t = dbo.StkDepots, s = dbo.StkDepots |
 |
|
|
boku
Starting Member
5 Posts |
Posted - 2009-11-28 : 21:38:50
|
| Ah .... duh ... just change "table" to the actual name ... my bad, sorry for DP |
 |
|
|
|
|
|