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 2005 Forums
 Transact-SQL (2005)
 Nullif statement

Author  Topic 

miked1978
Starting Member

25 Posts

Posted - 2009-01-28 : 16:30:32
I'm getting a divide by zero error so I'm trying to do a nullif statement but I don't think i'm doing it right. Can someone please take a look.

sum(nullif([BCWSc]-[PrevBCWSc])/[PotHrs]),0) AS BCWSpEP

tonymorell10
Yak Posting Veteran

90 Posts

Posted - 2009-01-28 : 16:37:39
If I'm understanding you correctly, it would be:
SUM(([BCWSc]-[PrevBCWSc])/NULLIF([PotHrs],0)) AS BCWSpEP
Go to Top of Page

miked1978
Starting Member

25 Posts

Posted - 2009-01-28 : 16:57:45
quote:
Originally posted by tonymorell10

If I'm understanding you correctly, it would be:
SUM(([BCWSc]-[PrevBCWSc])/NULLIF([PotHrs],0)) AS BCWSpEP



Yes this worked. Thank you very much
Go to Top of Page

tonymorell10
Yak Posting Veteran

90 Posts

Posted - 2009-01-28 : 17:07:03
Your welcome. :)
Go to Top of Page
   

- Advertisement -