Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2016
    Posts
    1

    Post Unanswered: DB2 query not working

    Hello,

    Apologize if this is a simple question but I am just unable to get an answer for this.

    I have two tables cust.costone and cust.costtwo

    select * from cust.custone
    SLNO LOCATION COST
    1038319 4 99.80

    select * from cust.custtwo
    SLNO LOCATION COST
    1038319 4 99.81

    The below query should not pick any record as the cost difference is 0.01, but it does.

    select one.SLNO,one.location,decimal(one.cost,15,4) as onecost,decimal(two.cost,15,4) as twocost from cust.costone one
    inner join cust.costtwo two on two.upc=one.upc
    where abs(one.cost-two.cost) > 0.01

    The result is:
    SLNO LOCATION ONECOST TWOCOST
    1038319 4 99.8000 99.8100

    Do you know why it does not ignore the records even though the difference is 0.01?


    Regards,
    Vips

  2. #2
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hello,

    Have you tried this?

    abs(dec(one.cost,15,4)-dec(two.cost,15,4)) > 0.01
    Regards,
    Mark.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •