I have an error coming up "Divide by zero error encountered." in SQL Server 2005. I understand that i have few rows that are are getting divided by Zero that results in this error. So i was wondering if can eliminate this error when the divisor is zero. if the divisor is 0, it should return 0. How can i do that?
sum(isnull(cast(S.S_AmountCollected as numeric(10, 2)), 0)) / sum(isnull(cast(S.AmountSold as numeric(10, 2)), 0))
Thank you!