How do I fix divide by zero error message?

I'm using the following formula to create a new column and I'm getting an error message that says 'Divide by zero error encountered'.  How do i fix this?

cast((rate/quantity) as numeric (9,2)) PerRate

Thanks.
vsllcAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
simple CASE syntax:
cast( CASE WHEN quantity = 0 THEN 0 ELSE rate/quantity END as numeric (9,2)) PerRate

Open in new window

0
 
Aneesh RetnakaranDatabase AdministratorCommented:
Hello vsllc,


case when quantity >o then cast((rate/quantity) as numeric (9,2))    else 0  end PerRate


GOD BLESS,

Aneesh R.
0
 
vsllcAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.