Answered by:
round a number in oracle

Question
-
User-644330731 posted
dear all,
i need to round a number to its whole number like if the number is 15500 i need to round it to 15000. ,14450 then 14400 etc.
Wednesday, May 21, 2014 5:19 AM
Answers
-
User-902516579 posted
Hi,
Have you tried ROUND(num)?
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions135.htm
HTH, Benjamin
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 22, 2014 6:52 AM -
User269602965 posted
TRUNC(var, -3)
TRUNC(15500,-3) = 15000
TRUNC(15700,-3) = 15000
If you need to round UP then you will have to use ROUND function
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 22, 2014 3:30 PM -
User281315223 posted
Have you tried using the ROUND function?
It accepts two parameters, the first being the value or column that you intend to round and the second can accept a variety of different arguments to designate how the value would be rounded.
For example, if you wanted to round your value to the nearest thousand, you might use :
SELECT ROUND(yourColumnToRound 1000)
or if you needed to round to the nearest hundreth, you might use :
SELECT ROUND(yourColumnToRound 100)
Typically, the values that you provided would round up, so if you wanted to explicitly handle these to round down, you might consider subtracting 1 from them (to trigger a rounding down effect on these "halfway" values). I'm sure there is likely some "rounded floor" function that someone with more experience in Oracle could provide that might be a bit cleaner than that approach.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 22, 2014 3:43 PM
All replies
-
User-902516579 posted
Hi,
Have you tried ROUND(num)?
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions135.htm
HTH, Benjamin
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 22, 2014 6:52 AM -
User269602965 posted
TRUNC(var, -3)
TRUNC(15500,-3) = 15000
TRUNC(15700,-3) = 15000
If you need to round UP then you will have to use ROUND function
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 22, 2014 3:30 PM -
User281315223 posted
Have you tried using the ROUND function?
It accepts two parameters, the first being the value or column that you intend to round and the second can accept a variety of different arguments to designate how the value would be rounded.
For example, if you wanted to round your value to the nearest thousand, you might use :
SELECT ROUND(yourColumnToRound 1000)
or if you needed to round to the nearest hundreth, you might use :
SELECT ROUND(yourColumnToRound 100)
Typically, the values that you provided would round up, so if you wanted to explicitly handle these to round down, you might consider subtracting 1 from them (to trigger a rounding down effect on these "halfway" values). I'm sure there is likely some "rounded floor" function that someone with more experience in Oracle could provide that might be a bit cleaner than that approach.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 22, 2014 3:43 PM