ROUNDMAGIC

ROUNDMAGIC (expression)

Parameters

  • expression - any valid numeric expression.

Description

This function rounds numbers in a good way, but it is slow. It has a special handling for numbers around 0. Only numbers smaller or equal +/-1000000000000 are supported. The value is converted to a String internally, and then the last last 4 characters are checked. '000x' becomes '0000' and '999x' becomes '999999', which is rounded automatically. This method returns a double.

Example

Rounds every Player's age:

SELECT name, ROUNDMAGIC(AGE/3*3) FROM Player;