当前位置: 代码迷 >> Sql Server >> 请问一上关于SQL变量的小数有关问题
  详细解决方案

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

热度:97   发布时间:2016-04-25 00:55:12.0
请教一下关于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

加了小数点之后,隐式转换数据类型
  相关解决方案