Hi Everyone,
This one is driving me crazy.
I have three tables: purchase_order, purchase_order_ bom, and rog_bom.
The table purchase_order_ bom is a list of parts ordered for the purchase order. The table rog_bom is a list of parts received for the purchase order (ROG stands for receipt of goods).
I want to run a query that looks through table purchase_order but only show the purchase orders that have received less parts than the total number of parts order. Basically the purchase orders that haven't been fully received.
table purchase_order:
ID INT
table purchase_order_ bom:
ID INT
po_ID INT
quantity INT
product_ID INT
table rog_bom:
ID INT
po_ID INT
quantity INT
product_ID INT
I thought it would be something like this (but this shows only one purchase_order row):
Thank you!
Andy
This one is driving me crazy.
I have three tables: purchase_order, purchase_order_ bom, and rog_bom.
The table purchase_order_ bom is a list of parts ordered for the purchase order. The table rog_bom is a list of parts received for the purchase order (ROG stands for receipt of goods).
I want to run a query that looks through table purchase_order but only show the purchase orders that have received less parts than the total number of parts order. Basically the purchase orders that haven't been fully received.
table purchase_order:
ID INT
table purchase_order_ bom:
ID INT
po_ID INT
quantity INT
product_ID INT
table rog_bom:
ID INT
po_ID INT
quantity INT
product_ID INT
I thought it would be something like this (but this shows only one purchase_order row):
Code:
SELECT *, po.ID AS po_ID FROM purchase_order po WHERE (SELECT SUM(quantity) AS po_bom_total FROM purchase_order_bom po_bom WHERE po_bom.po_ID=po.ID) < (SELECT SUM(quantity) FROM rog_bom WHERE rog_bom.po_ID=po.ID)
Andy
Comment