如何在SQL中使用两个不同的列进行求和 [英] How to sum using two different column in SQL
本文介绍了如何在SQL中使用两个不同的列进行求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有两个不同的表假设table1和table2在这里我想用子查询&来计算表格(table1 + table2)的总数量。加入赞。
我的尝试:
从table1中选择Sum((isnull(cast(Quantity as float),0)))
从table2中选择Sum((isnull(cast(Quantity as float),0))) / pre>
i我使用这两个不同的查询来获得结果你可以建议我单个查询。解决方案
从这个中选择select(从table1中选择Sum(isnull(cast(Quantity as float),0))+(选择Sum(isnull)(cast(Quantity as float), 0))来自table2)
hello
I have two different table suppose table1 AND table2 here i want to calculate the Total Quantity from both the table (table1 + table2) using sub query & join Like.
What I have tried:
Select Sum((isnull(cast(Quantity as float),0))) from table1 Select Sum((isnull(cast(Quantity as float),0))) from table2
i am using this two different query for getting the result can you suggest me to single query.解决方案Adapt from thisselect (select Sum(isnull(cast(Quantity as float),0)) from table1) + (select Sum(isnull(cast(Quantity as float),0)) from table2)
这篇关于如何在SQL中使用两个不同的列进行求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文