b表:要select cid,sum(count) from b where cid=1 group by cid;
a表: 要select cid,sum(amount) from a where cid=1 group by cid;
需要将两条select统计值一起展示,解决如下:
--缺少对应列这里为了统计用0代替(数据类型要要致),
select cid,sum(a),sum(b)
from (SELECT cid, a.amount a, 0 'b' from a where a.cid = 1
union
select cid, 0, b.`count` b from b where b.cid = 1) c
group by c.cid;