Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sum of fields values in a table

Author  Topic 

manu
Starting Member

41 Posts

Posted - 2005-10-18 : 02:48:49
Hello

I want to get sum of 4 fields in a sql query result.

suppose i have a table with 4 fields (a,b,c,d) and 4 records for each of them.

i want that my query result should display

1. sum of individual field records( i have done this with sum(a))

2. sum of sum of final 4 fields (sum(a) + sum(b) + sum(c)+ sum(d))

is it possible. Pls help me in doing second step.

Munish Gupta



madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-18 : 02:56:17
This will work if the fields are not null

Select sum(a+b+c+d) from yourTable

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

manu
Starting Member

41 Posts

Posted - 2005-10-18 : 03:52:14
Thanks a lot sir

you have again solved my problem.

it is wonderful.

Thanks again

Munish Gupta
Go to Top of Page
   

- Advertisement -