Divide by zero error

  • Use ref

    Update a

    set HF56390 =

    Convert(Numeric(9,2),4.00*HC85230,0)/HF00340*100

    From H_PRO_QF a,H_FAVG_Q b,H_I_QP c

    Where a.Key = b.Key and a.Key = c.Key and

    a.Pedate = b.Pedate and a.Pedate = c.Pedate and a.status = 1

    While i am running the above query, getting divide by zero error

  • assumning if that field HF00340 is zero, you want to set that result to zero, else the calcualtion:

    Update a

    set HF56390 =

    CASE

    WHEN HF00340 = 0

    THEN 0

    ELSE Convert(Numeric(9,2),4.00*HC85230,0)/HF00340*100

    END

    From H_PRO_QF a,H_FAVG_Q b,H_I_QP c

    Where a.Key = b.Key

    and a.Key = c.Key

    anda.Pedate = b.Pedate

    and a.Pedate = c.Pedate

    and a.status = 1

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks a lot

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply