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中显示小数点后两位数


基础教程推荐
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01