ROUND(X), ROUND(X,D)
Rounds the argument X
to D
decimal places. The rounding algorithm depends on the data type of X
. 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.
SELECT ROUND(-1.23); +--------------+ | ROUND(-1.23) | +--------------+ | -1 | +--------------+ SELECT ROUND(-1.58); +--------------+ | ROUND(-1.58) | +--------------+ | -2 | +--------------+ SELECT ROUND(1.58); +-------------+ | ROUND(1.58) | +-------------+ | 2 | +-------------+ SELECT ROUND(1.298, 1); +-----------------+ | ROUND(1.298, 1) | +-----------------+ | 1.3 | +-----------------+ SELECT ROUND(1.298, 0); +-----------------+ | ROUND(1.298, 0) | +-----------------+ | 1 | +-----------------+ SELECT ROUND(23.298, -1); +-------------------+ | ROUND(23.298, -1) | +-------------------+ | 20 | +-------------------+
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/round/