Solved

ceil or round in oracle

Posted on 2013-05-23
9
558 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
Comment Utility
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
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 13

Expert Comment

by:Alexander Eßer [Alex140181]
Comment Utility
... 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
Comment Utility
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
Comment Utility
formatted rounded to 2 decimals....


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

Expert Comment

by:PortletPaul
Comment Utility
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
Comment Utility
thanks
0

Featured Post

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.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now