Last post May 22, 2014 03:43 PM by Rion Williams
May 21, 2014 05:19 AM|priya15_patel|LINK
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.
May 22, 2014 06:52 AM|Perkinsville|LINK
Have you tried ROUND(num)?
May 22, 2014 03:30 PM|Lannie|LINK
TRUNC(15500,-3) = 15000
TRUNC(15700,-3) = 15000
If you need to round UP then you will have to use ROUND function
May 22, 2014 03:43 PM|Rion Williams|LINK
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.