Mega Code Archive

 
Categories / MySQL Tutorial / Math Numeric Functions
 

ROUND(X), ROUND(X,D) rounds the argument X to D decimal places

D defaults to 0 if not specified. D can be negative to cause D digits left of the decimal point of the value X to become zero. mysql> mysql> SELECT ROUND(-1.23); +--------------+ | ROUND(-1.23) | +--------------+ |           -1 | +--------------+ 1 row in set (0.00 sec) mysql> SELECT ROUND(-1.58); +--------------+ | ROUND(-1.58) | +--------------+ |           -2 | +--------------+ 1 row in set (0.00 sec) mysql> SELECT ROUND(1.58); +-------------+ | ROUND(1.58) | +-------------+ |           2 | +-------------+ 1 row in set (0.00 sec)