问题描述
嗨
这是下午raj thakur我在SQL查询中有一个总和问题。我想在sql server2005中做一个多重列的总和。我有一个像
这样的表
ID印地语Pol_Science历史数学总计
- - ----- -------- ------ ----- ----
1 67.00 67.00 89.00 89.00?
2 89.00 89.00 88.00 67.00?
3 55.00 65.00 69.00 90.00?
4 56.00 78.00 98.00 67.00?
我想在每一行的总数中加总乘数列。
喜欢这样
ID - 印地语 - Pol_Science - 历史---数学---总计
- - ----- -------- ------ ----- ----
1 - 67.00 --- 67.00 --- 89.00 --- 89.00 --- 312.00
2 - 89.00 --- 9.00 - - 88.00 --- 67.00 --- 333.00
3 - 55.00 --- 65.00 --- 69.00 --- 90.00 --- 279.00
4 - 56.00 --- 78.00 --- 98.00 --- 67.00 --- 299.00
提前谢谢
hi
this is hem raj thakur I have a sum problem in a sql query. I want to do Sum of a multipal column in a sql server2005.I have a table like
ID Hindi Pol_Science History Math Total
-- ----- -------- ------ ----- ----
167.0067.00 89.0089.00 ?
289.0089.00 88.0067.00 ?
355.0065.00 69.0090.00 ?
456.0078.00 98.0067.00 ?
I wanna "sum" of multipal "column" in "total" in per single row.
like this
ID -- Hindi -- Pol_Science -- History --- Math --- Total
-- -- ----- -------- ------ ----- ----
1 --67.00 ---67.00 --- 89.00---89.00 --- 312.00
2 --89.00 --- 9.00 --- 88.00 --- 67.00 --- 333.00
3 --55.00 --- 65.00 --- 69.00 --- 90.00 --- 279.00
4 --56.00 --- 78.00 --- 98.00 --- 67.00 --- 299.00
thanks in advance
推荐答案
select a,b,c,d,(a+b+c+d) as total from table_name
用你的列名替换a,b,c,d ..
replace a,b,c,d with your column name..
这篇关于sql server2005中列的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!