Home > Database > Mysql Tutorial > 实例详解mysql ROUND()函数的四舍五入

实例详解mysql ROUND()函数的四舍五入

WBOY
Release: 2018-10-27 17:01:45
Original
1934 people have browsed it

这篇文章主要介绍了mysql ROUND()函数的四舍五入,有一定的参考价值,感兴趣的朋友可以看看,希望对你有所帮助!

ROUND(X) 

返回参数X的四舍五入的一个整数。 

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

注意返回值被变换为一个BIGINT! 

ROUND(X,D) 
返回参数X的四舍五入的有D为小数的一个数字。如果D为0,结果将没有小数点或小数部分。 

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

注意返回值被变换为一个BIGINT! 

【相关教程推荐】

1. mysql数据库图文教程 

2. MySQL 5.1参考手册下载 

3. bootstrap教程 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template