将选定的总计添加到另一个总计SQL Server 2008中 [英] Adding selected totals to another total SQL server 2008
问题描述
嗨
我的数据库输出如下所示:
-------------------------------------------------- -------------
客户| TotalMonth1 | totalMonth2 | TotalMonth3 | TotalCurrent
-------------------------------------------------- -------------
保罗| R 2012.02 | R 2021.03 | R 205411.99 | R 12004.52 |
现在,我想在select语句上添加一列,以添加TotalMonth1,totalMonth2,TotalMonth3的月份总数.
所以像
SELECT SUM(TotalMonth1 + totalMonth2 + TotalMonth3) as TotalLastMonths
有任何建议吗?
select Client,TotalMonth1,totalMonth2,TotalMonth3 ,totalcurrent,SUM(TotalMonth1 + totalMonth2 + TotalMonth3) as TotalLastMonths from table1
Hi
My database output looks as follows :
---------------------------------------------------------------
Client | TotalMonth1 | totalMonth2 | TotalMonth3 | TotalCurrent
---------------------------------------------------------------
Paul | R 2012.02 | R 2021.03 | R 205411.99 | R 12004.52 |
Now I want to add a column on the select statement that adds the totals of the month for TotalMonth1, totalMonth2, TotalMonth3.
so something like
SELECT SUM(TotalMonth1 + totalMonth2 + TotalMonth3) as TotalLastMonths
any suggestions?
select Client,TotalMonth1, totalMonth2 , TotalMonth3,totalcurrent, SUM(TotalMonth1 + totalMonth2 + TotalMonth3) as TotalLastMonths from table1
这篇关于将选定的总计添加到另一个总计SQL Server 2008中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!