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 |
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-07-21 : 09:19:51
|
| Thanks for reading and all the past help.I am summing financial data on account level and my select statement contains . . .(-sum(case when dbo.Trans.TransType = 'WAGER' then DeltaCash else 0 end) + sum(case when dbo.Trans.TransType = 'CANCELWAGER' then Deltacash else 0 end)) / (sum(case when dbo.Trans.TransType = 'DEPOSIT' then DeltaCash else 0 end)) as RtDIn some cases there is no deposit thus I am trying to divide by zero, how do I remove the error and return a null value?Thanks in advance. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-07-21 : 09:23:01
|
NULLIF(sum(case when dbo.Trans.TransType = 'DEPOSIT' then DeltaCash else 0 end),0) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-07-21 : 09:35:26
|
| Thanks webfred, you have answered a few of my questions now. Its greatly appreciated and I'm sure you will be pleased to know I am learning just find it hard to get started on the right track.Thanks again. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-07-21 : 09:53:35
|
You are always welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|