SQL Query to sum fields from different tables

前端 未结 5 1352
無奈伤痛
無奈伤痛 2020-12-30 15:57

I\'m a humble programmer that hates SQL ... :) Please help me with this query.

I have 4 tables, for example:

Table A:
Id Total
1  100
2  200
3  500

         


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-30 16:10

    Try this code SELECT Total=isnull((Select Sum(Isnull(Amount,0)) from table a),0)+isnull((Select Sum(isnull(Amount,0)) from table b),0)+isnull((Select Sum(isnull(Amount,0)) from table c),0)

提交回复
热议问题