字段Amout为Varchar类型的小数数值,查询语句怎么写才能直接where amount='7.9'
小弟,遇到如下问题,望前辈指导,谢谢!
已知字段Amount为Varchar类型,amount的值为小数数值,现在想要查询所有满足amount='7.9'的记录。
小弟直接用
1. select *from sales_d where amount='7.9'会直接爆varchar冲突。
2. select *from sales_d where convert(int,amount)='7.9'还是爆varchar冲突
3. select *from sales_d where convert(int,convert(numeric(18,9),amount))='7.9'同样出错。
最后使用select *From sales_d where convert(int,cast(amount as float))>='7' and convert(int,cast(amount as float))<'7',这样语句没有爆错。。。
求大神,有没有办法可以直接找出amount转换为数值等于7.9的记录呢, 非常感谢!!!