如何在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

相关文章