• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

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.
0
vsllc
Asked:
vsllc
1 Solution
 
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

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now