sql使用union all进行多张表相同字段求和

 

select sum(f1) fa from (
  select sum(f2) fb  from t1
   union all
   select sum(f3) fc  from t2
)

两个表t1和t2得 f2 , f3,同一个意义,可以一起sum,通过 union all 合并两个表得数据

 

posted @ 2022-02-24 13:44  叨叨的蜗牛  阅读(2663)  评论(0)    收藏  举报