Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase «««123

How to join multiple tables (SQL) to find the difference between an order and shipped quantities? Expand / Collapse
Posted Friday, July 12, 2013 10:58 AM



Group: General Forum Members
Last Login: Tuesday, December 6, 2016 8:08 PM
Points: 16,145, Visits: 16,850
I am not sure exactly what you are looking for but I think this is close based on your original post.

select o.ID as OrderID, oi.ItemNumber as ItemOrdered, oi.QtyToShip as QuantityOrdered,
sa.ProductCode as ShippedItem, sa.Qty as QuantityShipped, oi.QtyToShip - ISNULL(sa.Qty, 0) as AmountMissing
from myorder o
join orderITEMS oi on oi.OutboundDeliveryID = o.ID
left join Shipping s on s.PO = o.OrderRef1
left join ShippingArchive sa on sa.StatusID = s.ID


Need help? Help us help you.

Read the article at for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1473150
Posted Friday, July 12, 2013 11:21 AM


Group: General Forum Members
Last Login: Wednesday, July 17, 2013 7:41 AM
Points: 13, Visits: 8
Thank you so much! This is an awesome basis on which to finish my query. I have to add a lot of filtering and additional logic in.

Deepest appreciation!

I need to find someone that I can pay to consult on my SQL queries, it would make my effectiveness go through the roof. Any suggestions as to how or where to find a consultant that I could call and discuss my query issues with on an as needed basis?
Post #1473157
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse