请教:比较小数后2位大小

netboygg 2008-12-01 08:11:46
有个float字段里面有一些数据

70.14
78.02
79.09
.....
怎么只把小数点后2位的大小比较出来 比如说大于0.12的

象上面的比较的话就只有 70.14满足这个条件
...全文
77 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
netboygg 2008-12-01
  • 打赏
  • 举报
回复
感激2位大哥帮助
twgxzjk 2008-12-01
  • 打赏
  • 举报
回复

借用楼上测试数据:
declare @t table(num float)
insert @t select 70.14
insert @t select 78.02
insert @t select 79.09
insert @t select 10


select * from @t where num-cast(num as int)>0.12
twgxzjk 2008-12-01
  • 打赏
  • 举报
回复

借用楼上测试数据:
declare @t table(num float)
insert @t select 70.14
insert @t select 78.02
insert @t select 79.09
insert @t select 10


select * from @t where num-cast(num as int)>0.12
水族杰纶 2008-12-01
  • 打赏
  • 举报
回复
declare @t table(num float)
insert @t select 70.14
insert @t select 78.02
insert @t select 79.09
insert @t select 10
select * from @t where cast('0'+rtrim(right(num,len(num)-charindex('.',num)+1))as float)>0.12 and charindex('.',num)>0
/*num
-----------------------------------------------------
70.140000000000001
*/
hyde100 2008-12-01
  • 打赏
  • 举报
回复
declare @n table
(
a float
)


insert into @n values(70.14)
insert into @n values(78.02)
insert into @n values(79.09)

declare @i float
set @i = 0.12
select * from @n
where right(round(a,2),2) > right(@i,2)

结果:
70.14

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧