[英]DB2 how to sum two column from two different table
Select sum(amt) as totalA from tableA where id>10;
Select sum(amount) as totalB from tableB where people = 'JOSH';
What is the best way if the objective is to have sum(totalA + totalB)
? 如果目标是
sum(totalA + totalB)
的最佳方法是什么?
select sum(total) from
(
select sum(amt) as total from tableA where id>10
union all
select sum(amount) from tableB where people = 'JOSH'
) as q
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.