我有两张桌子促销(c_id)(net_amount)和customer_payment(c_id)(received_amount) 我得到的结果是1,80,000而不是90,000。 我的查询是
select sum(s.net_amount)-sum (cp.recived_amount) from customer_payments cp
join sale s on cp.Customer_id = s.customer_id
答案 0 :(得分:1)
选择 (SELECT SUM(sale.net_amount)FROM sale) - (SELECT SUM(customer_payments.recived_amount)FROM customer_payments)