I have a wide variety of numbers In the ten thousands, thousands, hundreds, etc
I would like to compute the rounding to the highest place value ex:
Starting #: 2555.5 Correctly Rounded : 3000
——
More examples ( in the same report )
Given: 255 Rounded: 300
Given: 25555 Rounded: 30000
Given: 2444 Rounded: 2000
But with the Round() or Ceil() functions I get the following
Given: 2555.5 Did not want : 2556
Any ideas ??? Thank you in advance
You can combine numeric functions like this
See fiddle
Explanation:
LOG(10, number)gets the power you need to raise 10 to in order get the number. E.g., LOG(10, 255) = 2.40654 and 10^2.40654 = 255TRUNC(LOG(10, col))the number of digit without the leading digit (2).POWER(10,TRUNC(LOG(10, col)))converts, e.g., 255 to 100.ROUND(2.55) = 33 * 100 = 300.By using the Oracle ROUND function with a second parameter specifying the number of digits with a negative number of digits, we can simplify the select command (see fiddle)
You can also use this to round by other fractions like quarters of the main number:
see fiddle