Banker's Rounding in Oracle

1.3k Views Asked by At

Is there any internal function in Oracle to support Banker's rounding, I need to use half to odd Banker's rounding in a select query

1

There are 1 best solutions below

4
MT0 On BEST ANSWER

To round to the nearest odd integer:

CASE
  WHEN MOD( ABS( value ), 2 ) = 1.5
  THEN TRUNC( value )
  ELSE ROUND( value )
END

To round to the nearest odd hundredth:

CASE
  WHEN MOD( ABS( value ), 0.02 ) = 0.015
  THEN TRUNC( value, 2 )
  ELSE ROUND( value, 2 )
END