字符转数字比大小

xiaoxinpaigu 2008-01-07 07:52:14
有一个字段为char型,里面的数据是 10.23、11.50、15.00等带两位小数的数据,现在我需要找出大于13的数据,请问该如何写?
...全文
330 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouchunyu 2008-01-08
  • 打赏
  • 举报
回复
select * from 表名 where cast(字段 as numeric(8,2))>13

我用MSSQL2000测试怎么能行啊?

xiaoxinpaigu 2008-01-08
  • 打赏
  • 举报
回复
不行啊?
提示“将数字类型varchar转换为numeric时出错”
!!!

我用的时MSSQL2000
wuxinyuzhu 2008-01-08
  • 打赏
  • 举报
回复

我感觉这要更简单
select * from table where col>convert(varchar(10),13)
中国风 2008-01-07
  • 打赏
  • 举报
回复
ISNUMERIC(col)加多一个条件, 只对有效数字作比较
中国风 2008-01-07
  • 打赏
  • 举报
回复
1楼用oracle。???


select * from T where ISNUMERIC(col)=1 and convert(decimal(18,2),COl)>13
cxmcxm 2008-01-07
  • 打赏
  • 举报
回复
用convert或cast将字符串类型先转为数字型再比较
就如楼上
cast(字段 as numeric(8,2))>13也可写成convert(numeric(8,2),字段)>13
-狙击手- 2008-01-07
  • 打赏
  • 举报
回复
select * 
from 表名
where cast(字段 as numeric(8,2))>13
pt1314917 2008-01-07
  • 打赏
  • 举报
回复

select * from 表名 where cast(字段 as numeric(8,2))>13
wzy_love_sly 2008-01-07
  • 打赏
  • 举报
回复
declare @tb table (s varchar(10))
insert into @tb select '10.23'
insert into @tb select '11.50'
insert into @tb select '15.00'


select * from @tb where cast(s as decimal(4,2))>13.00


15.00
JYYCOM 2008-01-07
  • 打赏
  • 举报
回复
select column from tablename where To_number(column)>13\
不知道对不对

34,590

社区成员

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

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