Solved

ceil or round in oracle

Posted on 2013-05-23
9
563 Views
Last Modified: 2013-05-23
select (10.5*15.01) from dual


157.605

I tried using ceil and also round

I get the value 158.

I need help in decimals. 605 has to be 61 -- 157.61
0
Comment
Question by:anumoses
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 39190625
select round(10.5*15.01,2) from dual


select ceil(100*10.5*15.01)/100 from dual
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 39190638
select
  round(x,0)
, round(x,3)
, ceil(x)
, floor(x)
from (
      select (10.5*15.01) as x from dual
     )

Open in new window

ROUND(X,0)      ROUND(X,3)      CEIL(X)      FLOOR(X)
158                 157.605         158         157

not sure what you are asking for
0
 
LVL 6

Author Comment

by:anumoses
ID: 39190666
select (ceil(100*70*15.01)/100) from dual
   
   select round(70*15.01,2) from dual

1050.7

Is there a ways to have 1050.70?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
ID: 39190676
if you want formatting, convert it to a string

select to_char((ceil(100*70*15.01)/100),'fm9999.00') from dual
   
   select to_char(round(70*15.01,2),'fm9999.00') from dual
0
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39190757
... or just do the formatting "later" within your frontend...

But the point is: what exactly are you asking for / what do you want to do ?!
0
 
LVL 6

Author Comment

by:anumoses
ID: 39190761
I am asking for formatting the numbers that I get as results. rounding the decimals to 2 decimals.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 39190771
formatted rounded to 2 decimals....


 select to_char(round(70*15.01,2),'fm9999.00') from dual
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 39190844
http://www.techonthenet.com/oracle/functions/
http://www.techonthenet.com/oracle/functions/ceil.php
http://www.techonthenet.com/oracle/functions/floor.php
http://www.techonthenet.com/oracle/functions/round_nbr.php

with round() YOU specify the number of decimals points as the second parameter in that function

for "display" you use to_char, THEN there you may also specify the number of decimal points to show for presentation by the "format mask" (which is the second parameter to that function).
http://www.techonthenet.com/oracle/functions/to_char.php

I'd suggest you get familiar with these functions
0
 
LVL 6

Author Closing Comment

by:anumoses
ID: 39191092
thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ORA-01008: not all variables bound. 6 59
How to Gracefuly recover in Racle stored procedure 1 30
Oracle dataguard 5 33
Create file system directory from Oracle 10g 4 19
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question