读书人

请问一上关于SQL变量的小数有关问题

发布时间: 2012-12-23 11:28:15 作者: rapoo

请教一下关于SQL变量的小数问题
declare @IRatio decimal(4,4)

select @IRatio=10/30

select @IRatio

如上,我要让 @IRatio 显示为 0.3333 请问要如何处理?
[最优解释]
declare @IRatio decimal(4,4)

select @IRatio=10.0/30

select @IRatio


[其他解释]
declare @IRatio decimal(4,4)

select @IRatio=10*1./30

select @IRatio
[其他解释]
declare @IRatio decimal(4,4)

select @IRatio=10.0/30

select @IRatio

加了小数点之后,隐式转换数据类型

读书人网 >SQL Server

热点推荐