Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Divide by zero error encountered 1

Status
Not open for further replies.

soutener

IS-IT--Management
Jul 12, 2006
56
0
0
US
Divide by zero error encountered."

i get above error when i try this code...


Code:
UPDATE SET AVGSL=NETDOL/NETQTY

my data types are decimal
i'm trying to figure out the average selling price

thanks
 
This can only occur if NETQTY is zero. You have a couple ways to deal with this.

Code:
Update Table
Set    AVGSL= Case When NetQty = 0
                   Then 0
                   Else NETDOL/NETQTY
                   End

or

Code:
Update Table
Set    AVGSL= NETDOL/NETQTY
Where  NetQty <> 0



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top