如何使用id减去两个查询

时间:2019-06-14 06:07:09

标签: mysql

如何减去两个查询量字段比较ID。

select customer_id,sum(amount) as totalamount from orders group by customer_id
 UNION ALL 
select id,sum(salary) as totalamount from customers group by id;

select customer_id,sum(amount) as totalamount from orders group by customer_id 
UNION ALL 
select id,sum(salary) as totalamount from customers group by id;

使用id减去两个查询结果

0 个答案:

没有答案