I have a table (Inventory_Line) where LID is auto increment and IID is a single number referring to the inventory date, PID is a numeric part#. We use this table for inventory.
LID IID NAME PID QTY
--- --- ------ --- ---
1 1 Part A 213 12
2 1 Part B 200 15
3 2 Part A 213 9
4 2 Part B 200 7
We also have a table Order_Line
OLID OID NAME PID QTY
---- --- ------ --- ---
1 217 Part A 213 12
2 217 Part B 200 15
3 218 Part A 213 9
4 218 Part B 200 7
My goal is to show
((Previous Inventory Qty (Inventory_Line.IID=1)) AS PREV_INV +
(ORDERED Qty (Order_Line.OID = 217 AND 218)) AS ORDERED -
(Current Inventory Qty Inventory_Line.IID=2) AS CURRENT_INV) AS SOLD
WHERE PID = X
The output would be like this:
PID NAME PREV_INV ORDERED CURRENT_INV SOLD
--- ------ -------- ------- ----------- ----
213 Part A 12 21 9 24
We are using MS Access and I have some experience with Joins but I am kind of stuck on how to pull this off. Any help would be appreciated.
Are you thinking of something on these lines?
The above needs some work, but what should be done would be clearer with more input on the desired output.
Re comments