select convert(float,substring(规格,2,len(规格)-1))-5 from a_icitem_0 where 规格 like 'ф%%'--这样写可以查出结果来
select * from a_icitem_0 where 规格 like 'ф%%' and convert(float,substring(规格,2,len(规格)-1))>50
--这样写就报错a_icitem_0这是一个视图 规格字段类型为varchar 因为这个规格里面有个符号ф我想把它去掉然后再跟数字作比较
但是我写到条件时面的时候就报错了从数据类型 varchar 转换为 float 时出错。`请教大家该怎么办?
别眼高手低
如果不行的话你就把cast(字段 as float)aaa放到select里,aaa是别名。在where里再写aaa>50
你试试^_^
select convert(float,substring(规格,2,len(规格)-1)) as 'TC' from a_icitem_0 where 规格 like 'ф%%'
and TC>50
---消息 207,级别 16,状态 1,第 2 行
--列名 'TC' 无效。
cast(字段 as float)
convert(float,字段)