Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

rounding UP numbers in pl\sql

717817Jul 30 2010 — edited Jul 30 2010
Hi is there a way to round up numbers in pl\sql?
This post has been answered by Sven W. on Jul 30 2010
Jump to Answer

Comments

21205
round ()
doc: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions135.htm#SQLRF00698

Edited by: Alex Nuijten on Jul 30, 2010 2:40 PM
ORA_AJ
Just use ROUND Function...Whats the issue

AJ
Karthick2003
Kevin CK wrote:
Hi is there a way to round up numbers in pl\sql?
Yes oracle does. Did you try the document?
737905
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
Sven W.
Answer
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
Marked as Answer by 717817 · Sep 27 2020
Frank Kulash
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.
717817
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
717817
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 :)
1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 27 2010
Added on Jul 30 2010
8 comments
21,205 views