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)
 handling NULL

Author  Topic 

doran_doran
Posting Yak Master

179 Posts

Posted - 2008-07-01 : 11:19:49
SUM(dbo.slip_filtered.hour + dbo.slip_filtered.minute / 60) AS hours

I have NULL in the minute column. Should that have any effect on above sum. I was under the impression sql server handles NULL gracefully. Please advise.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-01 : 11:45:29
Use ISNull or Coalesce function.
Go to Top of Page

doran_doran
Posting Yak Master

179 Posts

Posted - 2008-07-01 : 12:09:16
hmm. r u sure i can use coalesce (which is similar to case function) cause it did not work for me. Also, with isnull i have to use if or case. Am I right? How would you re-write this SUM(dbo.slip_filtered.hour + dbo.slip_filtered.minute / 60) AS hour

sometime time minute or hour is null and i want to re-write it so that nulls are affecting the calculation. for example :

1+null = 1
Null + 30/60 = .5

Hope it makes sense.
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2008-07-01 : 12:34:06
Something like this:

SUM(isnull(dbo.slip_filtered.hour,0) + isnull(dbo.slip_filtered.minute,0) / 60) AS hour
Go to Top of Page

doran_doran
Posting Yak Master

179 Posts

Posted - 2008-07-01 : 12:57:42
Thanks van. Great job.
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2008-07-01 : 13:52:59
No problem...
Go to Top of Page
   

- Advertisement -