DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Round a decimal value

  1. #1
    Join Date
    Sep 2005
    Posts
    46

    Round a decimal value

    Dearl All,
    I have a problem with rounding decimal values. The scenario is that i'll have to apply rounding as per the user discretion. It can be round UP(always rounded upwards regardless of the value) or Round DOWN (always rounded downwards regardless of the value) or normal rounding(rounded up (if >= 5) or down (<5)).

    For ex:
    12.8936 round UP (3 decimal places) should give 12.894
    12.8936 round DOWN (3 decimal places) should give 12.893
    12.8936 round Normal (3 decimal places) should give 12.894

    Similarly
    12.8934 round UP (3 decimal places) should give 12.894
    12.8934 round DOWN (3 decimal places) should give 12.893
    12.8934 round Normal (3 decimal places) should give 12.893

    For Round DOWN i can use TRUNC function. For Round Normal i can use SQL's normal Round function. Is there any mechanism to implement Round UP in Oracle SQL?

    Please Help !!!

    regards
    Issac

  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712

    SQL> select trunc(12.8930000001+0.000999999999,3 ) from dual;

    TRUNC(12.8930000001+0.000999999999,3)
    -------------------------------------
    12.894

    SQL> select trunc(12.893+0.000999999999,3 ) from dual;

    TRUNC(12.893+0.000999999999,3)
    ------------------------------
    12.893
    Ales
    The whole difference between a little boy and an adult man is the price of toys

Posting Permissions

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


Click Here to Expand Forum to Full Width