Click here to Skip to main content
15,884,592 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
-- ----- -------- ------ ----- ----
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 ?

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
Posted
Updated 29-Aug-13 20:34pm
v2

1 solution

SQL
select a,b,c,d,(a+b+c+d) as total from table_name


replace a,b,c,d with your column name..
 
Share this answer
 
v2
Comments
Hem Raj Thakur 30-Aug-13 2:39am    
this answer is useful for me thank you very much.
[no name] 30-Aug-13 2:46am    
u r welcome..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900