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中显示小数点后两位数
基础教程推荐
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
