How to SUM and SUBTRACT using SQL?

前端 未结 6 1437
甜味超标
甜味超标 2020-12-09 08:09

I am using MySQL and I have two tables:

master_table

  • ORDERNO
  • ITEM
  • QTY

stock_bal

6条回答
  •  [愿得一人]
    2020-12-09 08:28

    Simple copy & paste example with subqueries, Note, that both queries should return 1 row:

    select
    (select sum(items_1) from items_table_1 where ...)
    -
    (select count(items_2) from items_table_1 where ...) 
    
    as difference
    

提交回复
热议问题