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.
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 hoursI 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. |
 |
|
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 hoursometime time minute or hour is null and i want to re-write it so that nulls are affecting the calculation. for example :1+null = 1Null + 30/60 = .5Hope it makes sense. |
 |
|
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 |
 |
|
doran_doran
Posting Yak Master
179 Posts |
Posted - 2008-07-01 : 12:57:42
|
Thanks van. Great job. |
 |
|
Van
Constraint Violating Yak Guru
462 Posts |
Posted - 2008-07-01 : 13:52:59
|
No problem... |
 |
|
|
|
|