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)
 fields operations

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-03-28 : 08:17:22
Rodriguez writes "Pleas how I can sum with null value in a SQL server view? I need that null value was considered 0 (cero) or empty string.
p.e
field1 field2 field3
<NULL> 2 3 field1+fiel2+field3=<NULL>
I need:
field1+field2+field3=5

Thank"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-03-28 : 08:18:28
SELECT IsNull(field1, 0) + IsNull(field2, 0) + IsNull(field3, 0) AS Total FROM myTable

You can learn more about IsNull() in Books Online. Also look up "COALESCE".
Go to Top of Page
   

- Advertisement -