SQL Server 中如何显示小数点后两位 [英] How to display two digits after decimal point in SQL Server

查看:30
本文介绍了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 中如何显示小数点后两位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆