位置:首页 > 数据库 > SQL在线教程 > SQL ROUND()函数

SQL ROUND()函数

ROUND(X)

ROUND(X,D)

此函数返回X四舍五入到最接近的整数。如果第二个参数D提供,则函数返回x四舍五入至小数点后D位。 D必须为正数或全部在小数点右侧的位将被删除。考虑下面的例子:

SQL>SELECT ROUND(5.693893);
+---------------------------------------------------------+
| ROUND(5.693893)                                         |
+---------------------------------------------------------+
| 6                                                       |
+---------------------------------------------------------+
1 row in set (0.00 sec)

SQL>SELECT ROUND(5.693893,2);
+---------------------------------------------------------+
| ROUND(5.693893,2)                                       |
+---------------------------------------------------------+
| 5.69                                                    |
+---------------------------------------------------------+
1 row in set (0.00 sec)