开发者

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

How to calculate a value from two other table columns in my SQL

How to calculate a value from two other table columns in my SQL

How to calculate a value from two other table columns in my SQL


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜