This discussion is archived
8 Replies Latest reply: Jul 30, 2010 7:03 AM by 717817

# rounding UP numbers in pl\sql

Currently Being Moderated
Hi is there a way to round up numbers in pl\sql?
• ###### 1. Re: rounding UP numbers in pl\sql
Currently Being Moderated
``round ()``

Edited by: Alex Nuijten on Jul 30, 2010 2:40 PM
• ###### 2. Re: rounding UP numbers in pl\sql
Currently Being Moderated
Just use ROUND Function...Whats the issue

AJ
• ###### 3. Re: rounding UP numbers in pl\sql
Currently Being Moderated
Kevin CK wrote:
Hi is there a way to round up numbers in pl\sql?
Yes oracle does. Did you try the document?
• ###### 4. Re: rounding UP numbers in pl\sql
Currently Being Moderated
``````SQL> SELECT ROUND(100.1234,2) FROM dual;

ROUND(100.1234,2)
-------------------
100.12

SQL> SELECT ROUND(1.123,1) FROM dual;

ROUND(1.123,1)
----------------
1.1

SQL> ``````
Edited by: AP on Jul 30, 2010 5:42 AM
• ###### 5. Re: rounding UP numbers in pl\sql
Currently Being Moderated
Maybe you are looking for CEIL.

``````with testdata as (select level/3-2 num from dual connect by level<=15)
select num, round(num), ceil(num)
from testdata;

NUM    ROUND   CEIL
------------------------------------------------
-1,67     -2     -1
-1,33     -1     -1
-1     -1     -1
-0,67     -1     0
-0,33     0     0
0     0     0
0,33     0     1
0,67     1     1
1     1     1
1,33     1     2
1,67     2     2
2     2     2
2,33     2     3
2,67     3     3
3     3     3``````
• ###### 6. Re: rounding UP numbers in pl\sql
Currently Being Moderated
Hi,

ROUND rounds numbers to the nearest integer. (Acutally, it can round to other powers of 10 as well, but let's just say integer for now.)
CEIL as Sven suggested, rounds to the next integer greater than its argument, so CEIL (1.003) returns 2.
What do you want to do about negative numbers? CEIL (-1.003) returns -1, because -1.003 < -1.

Also check out the FLOOR and TRUNC functions.
• ###### 7. Re: rounding UP numbers in pl\sql
Currently Being Moderated
Yes exactly what i was looking for,

I used round(x.yyyyy) but my problem with round was that it rounds off to the nearest integer which is not good for me coz whenever there is a .00001 it should round up to the next integer.

Let me try CEIL and see what that comes up with.

Thanks
• ###### 8. Re: rounding UP numbers in pl\sql
Currently Being Moderated
Hi Sven/Frank,

Yes it worked. i was starting to put all kind of conditions so that i get values to the next integer number.

Thanks a lot :)

#### Legend

• Correct Answers - 10 points