troubleshooting Question

Running total between 2 sql tables in Sql

Avatar of Michael Katz
Michael KatzFlag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
6 Comments1 Solution146 ViewsLast Modified:
The first table looks like this


StockCode      Warehouse      AvailQty                     SalesQty                   Remaining
0422 2001      BR-DROP      5200000.000000      1981299.230000      3218700.770000



The 2nd table looks like this
Ser3      StockCode      Ser                                  Warehouse   TrnType      Bin               Qty                               CusInvoice      VendGrn      Job
201508      0422 2001      2015080313165079      BR-DROP      A            BR-DROP       100000.000000                   
201509      0422 2001      2015091413551294      BR-DROP      A            BR-DROP       100000.000000                   
201511      0422 2001      2015111216063103      BR-DROP      A            BR-DROP       2000000.000000                   
201602      0422 2001      2016021214424950      BR-DROP      A            BR-DROP       3000000.000000            

What I need in table2 is to show where the 3218700.77000 will be subtracted....The first and second record will have 0 qty..but the 3rd record will have 218700.770000 and the 4th record will show 3000000.00000...

Hopefully this makes sense
ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004