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
 Transact-SQL (2000)
 Sum

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-28 : 08:21:43
MarioK writes "Hi all,
I try to Sum the total interest column

money Table
column interest
123.5
145.3
Null
.12
please show me. Thanks"

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-28 : 09:30:55
select sum(isnull(interest, 0)) as Interest_sum from Table

Go with the flow & have fun! Else fight the flow
Go to Top of Page

MarioK
Starting Member

20 Posts

Posted - 2005-01-28 : 12:15:04
Thankx very mucho spirit1
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2005-01-28 : 15:22:12
you don't really need to convert the Null values. The aggregates will ignore Null columns.

select sum(interest)
from MyTable

Both will yield the same answer but one is slightly more efficient.

(Yes, I'm retentive)

HTH

=================================================================

Our elections are free, it's in the results where eventually we pay. -Bill Stern, sports announcer (1907-1971)
Go to Top of Page
   

- Advertisement -