四舍五入,精確一位小數(沒分了,以后補) A 為:Decimal(18,6) 59.1499569 = 59.125.34999394 =25.3 49.49997474 =49.5 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select str('59.1499569',4,1)select str('25.34999394',4,1)select str('49.49997474',4,1) declare @int as decimal(18,6)set @int=59.1499569set @int =49.49997474 select convert(decimal(18,1),@int) 1楼的: select ltrim(str('9.23423',4,1)) select round(49.49997474 ,1,0) select @num=(round(444449.49997474,1,0))select @count=charindex('.','@num')+2select substring('@num',0,@count)结果是444449.5,后边没有多余的0 declare @Int decimal(18,4)set @Int=5.39select cast(round(@Int,1,0) as decimal(18,1)) 创建函数Create Function dbo.GetValue(@Int deciaml(18,6))returns decimal(18,1)begin Return(cast(round(@Int,1,0) as decimal(18,1)))end执行select dbo.GetValue(59.1499569) select dbo.GetValue(25.34999394)select dbo.GetValue(49.49997474)不过这么简单,函数好象没有必要,呵呵 关于统计的问题 帮忙改下sql语句:mssql收缩用户数据库日志 有道SQL题请求帮解释(在线等待...) 如何:取系统当前时间 学校3道sql server题,请帮忙 sqlserver脚本问题 百分求:如何提高大事务执行效率 高分求救!存储过程返回记录集的问题! 如何向sqlserver中写入图片字段数据 变量与列数据比较,出错,求解 求实际表合并的SQL语句 求教一个行转列的SQL语句问题
select str('25.34999394',4,1)
select str('49.49997474',4,1)
set @int=59.1499569
set @int =49.49997474
select convert(decimal(18,1),@int)
select round(49.49997474 ,1,0)
select @count=charindex('.','@num')+2
select substring('@num',0,@count)结果是444449.5,后边没有多余的0
set @Int=5.39
select cast(round(@Int,1,0) as decimal(18,1))
创建函数
Create Function dbo.GetValue(@Int deciaml(18,6))
returns decimal(18,1)
begin
Return(cast(round(@Int,1,0) as decimal(18,1)))
end执行
select dbo.GetValue(59.1499569)
select dbo.GetValue(25.34999394)
select dbo.GetValue(49.49997474)
不过这么简单,函数好象没有必要,呵呵