Latest web development tutorials

ROUND SQL function ()

ROUND function ()

ROUND () funzione per il campo numerico arrotondato al numero specificato di cifre decimali.

ROUND SQL () sintassi

SELECT ROUND(column_name,decimals) FROM table_name;

参数 描述
column_name 必需。要舍入的字段。
decimals 必需。规定要返回的小数位数。




SQL ROUND () esempi

ROUND (X): restituisce un parametro intero X arrotondato.

mysql> select ROUND(-1.23);
        -> -1
mysql> select ROUND(-1.58);
        -> -2
mysql> select ROUND(1.58);
        -> 2

ROUND (X, D): restituisce il parametro X ha arrotondato D è una cifra decimale. Se D è 0, il risultato non avrà alcun punto decimale o parte frazionaria.

mysql> select ROUND(1.298, 1);
        -> 1.3
mysql> select ROUND(1.298, 0);
        -> 1

NOTA: valore di ritorno ROUND viene convertito in un BIGINT!