mysql格式化小数保留小数点后两位(小数点格式化)
时间:2024-01-21 10:33:58
SELECT FORMAT(12562.6655,2);
结果:12,562.67
查看文档:Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has no decimal point or fractional part.整数部分超过三位的时候以逗号分割,并且返回的结果是string类型的。
mysql> SELECT FORMAT(12332.123456, 4);
-> '12,332.1235'
mysql> SELECT FORMAT(12332.1,4);
-> '12,332.1000'
mysql> SELECT FORMAT(12332.2,0);
-> '12,332'
没有达到预期结果,想要的结果不要以逗号分隔,
select truncate(4545.1366,2);
结果:4545.13,直接截取不四舍五入,还是有问题。
select convert(4545.1366,decimal);
结果:4545.14,达到预期。
标签:小数点格式化,保留小数点后两位
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python虚拟环境virtualenv的安装与使用
2023-07-01 00:23:00
golang中的并发和并行
2024-04-26 17:15:11
Python数据分析之matplotlib绘图详解
2022-11-21 16:34:30
![](https://img.aspxhome.com/file/2023/2/103602_0s.jpg)
SQL技巧:快速掌握一些异常精妙的SQL语句
2009-09-02 13:55:00
Python之is与==的区别详解
2021-08-23 21:00:04
![](https://img.aspxhome.com/file/2023/0/124690_0s.jpg)
程序员的七夕用30行代码让Python化身表白神器
2023-10-26 12:27:41
![](https://img.aspxhome.com/file/2023/3/113153_0s.png)
详解python中的线程与线程池
2022-02-02 18:27:19
SQL Server数据在不同数据库中的应用
2008-12-24 15:34:00
简单方法实现网页自动适应任何分辨率任何窗口大小
2008-09-13 19:28:00
Python模块_PyLibTiff读取tif文件的实例
2023-04-11 03:22:06
php使用pthreads v3多线程实现抓取新浪新闻信息操作示例
2023-10-12 19:21:46
![](https://img.aspxhome.com/file/2023/9/55619_0s.png)
python数据可视化之条形图画法
2021-08-07 13:43:22
![](https://img.aspxhome.com/file/2023/6/98966_0s.jpg)
python网络爬虫实现个性化音乐播放器示例解析
2021-10-06 10:14:51
![](https://img.aspxhome.com/file/2023/3/112763_0s.png)
tensorflow基本操作小白快速构建线性回归和分类模型
2022-09-16 17:13:37
![](https://img.aspxhome.com/file/2023/3/92513_0s.png)
Python descriptor(描述符)的实现
2021-12-22 09:07:56
![](https://img.aspxhome.com/file/2023/0/90400_0s.png)
Python3实现简单可学习的手写体识别(实例讲解)
2021-10-05 14:24:05
![](https://img.aspxhome.com/file/2023/7/102747_0s.png)
BootStrap学习系列之Bootstrap Typeahead 组件实现百度下拉效果(续)
2024-04-10 11:02:48
![](https://img.aspxhome.com/file/2023/6/136806_0s.png)
PHP实现表单处理方法详解
2023-05-25 07:39:18
SQL语句实现查询Index使用状况
2024-01-24 13:44:46
关于Python自动化操作Excel
2022-07-19 23:25:48