How to display two digits after decimal point in SQL Server(如何在SQL Server中显示小数点后两位数)
问题描述
我在SQL Server
中有一列float
数据类型的表我想返回带有 2 个小数位的 float
数据类型列值.
I have table which has a column of float
data type in SQL Server
I want to return my float
datatype column value with 2 decimal places.
例如:如果我插入12.3
,它应该返回12.30
for ex: if i insert 12.3
,it should return 12.30
如果我插入12
,它应该返回12.00
if i insert 12
,it should return 12.00
推荐答案
select cast(your_float_column as decimal(10,2))
from your_table
decimal(10,2)
表示您可以拥有一个最大总精度为 10 位的十进制数.小数点后2个,小数点前8个.
最大可能的数字是 99999999.99
decimal(10,2)
means you can have a decimal number with a maximal total precision of 10 digits. 2 of them after the decimal point and 8 before.
The biggest possible number would be 99999999.99
这篇关于如何在SQL Server中显示小数点后两位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在SQL Server中显示小数点后两位数


基础教程推荐
- 带有WHERE子句的LAG()函数 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01