mysql 不同两个表,两个字段 如何相减

select tid, a.sum-b.sumfrom (select tid, sum(num) as sum from A order by tid)a,(select tid, sum(num) as sum from B order by tid)bwhere a.tid = b.tid试一下上面的sql语句行不行
mysql 不同两个表,两个字段 如何相减
select tid, a.sum-b.sumfrom (select tid, sum(num) as sum from A order by tid)a,(select tid, sum(num) as sum from B order by tid)bwhere a.tid = b.tid试一下上面的sql语句行不行
2015-08-27
select AA.anum - BB.anum from
(select count(num) as anum, tid as atid from A group by tid) as AA,
(select count(num) as bnum, tid as btid from B group by tid) as BB
where AA.atid = BB.btid;2015-08-27
mengvlog 阅读 59 次 更新于 2025-10-30 11:59:50 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部