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

Thread: Rounding ?!

  1. #1
    Join Date
    Aug 2002
    Posts
    27
    Hi all,

    Is there an PL/SQL function f that can do the following:
    1)
    if x = 25.432
    then the function returns 25.435
    2)
    if x = 25.436
    then the function returns 25.440


    Regards

  2. #2
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    342
    I think this meets your requirements


    1 select
    2 ceil(25.430/5*1000)*5/1000 t0
    3 ,
    4 ceil(25.431/5*1000)*5/1000 t1
    5 ,
    6 ceil(25.432/5*1000)*5/1000 t2
    7 ,
    8 ceil(25.433/5*1000)*5/1000 t3
    9 ,
    10 ceil(25.434/5*1000)*5/1000 t4
    11 ,
    12 ceil(25.435/5*1000)*5/1000 t5
    13 ,
    14 ceil(25.436/5*1000)*5/1000 t6
    15 ,
    16 ceil(25.437/5*1000)*5/1000 t7
    17 ,
    18 ceil(25.438/5*1000)*5/1000 t8
    19 ,
    20 ceil(25.439/5*1000)*5/1000 t9
    21* from dual
    14:25:46 70 SQL> /

    T0 T1 T2 T3 T4 T5 T6
    ---------- ---------- ---------- ---------- ---------- ---------- ----------
    T7 T8 T9
    ---------- ---------- ----------
    25.43 25.435 25.435 25.435 25.435 25.435 25.44
    25.44 25.44 25.44


    Regards
    Gert

  3. #3
    Join Date
    Aug 2002
    Posts
    27
    THANK YOU VERY VERY MUCH FOR YOUR VALUABLE HELP

  4. #4
    Join Date
    Dec 2001
    Posts
    141
    Try this :

    select (case when substr(to_char(&x),-1) >5
    then round(&x,2)
    else to_number(substr(to_char(&x),1,length(to_char(&x))-1)||'5')
    end)
    from dual;

    You can put this query in a function ...
    Hope this help !
    Helene

  5. #5
    Join Date
    Aug 2002
    Posts
    27

    Thumbs up

    Thank you very much ....

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