How to calculate a value from two other table columns in my SQL
Can anyone help me understand how to create a result in a column from adding and subtracting values from two other tables/columns?
I have three tables each with a column named "qty":
qty_ad开发者_C百科d, qty_pull, qty_current
I need "qty_current" to reflect a result from the two other columns.
Erik
It is really hard to understand what exactly you want to do from your question but this might give you some direction:
SELECT part_no,
SUM(qty) -
( SELECT SUM(qty) FROM cartons_pulled
WHERE cartons_pulled.part_no = cartons_added.part_no ) AS current_qty
FROM cartons_added
GROUP BY part_no
精彩评论