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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros