I need to round a decimal in a sql query on Oracle 10g to the nearest even number. If the number is even, it should be returned. If the number is odd, the next even number should be returned.
This is what I want: 8.05 should return 8.06, 3.48 should return 3.48
How can I do this?
Thanks, Andrew
Advertisement
Answer
If you want to round e.g. to the second decimal even digit, you can do something like that: select round(3.43 / 0.02, 0) * 0.02;
that will produce 3.44
.
This can be extended as you wish: e.g. first decimal digit which is multiple of 3: select round(3.5452234 / 0.3, 0) * 0.3;
will give 3.6
.