[英]sql greater than statement returns values less than and greater than
I know my issue is that the value is a string but how can I work around it and return the correct results? 我知道我的问题是该值是一个字符串,但是如何解决该问题并返回正确的结果?
Here is my query and an excerpt of the results returned 这是我的查询和返回结果的摘录
select [Count of Disk Errors], _ResourceGuid from Inv_Hard_Disk_Errors
where _resourceguid in (select guid from vComputer where IsManaged = '1')
and [COUNT of Disk Errors] > '250'
order by 1 desc
Count of Disk Errors _ResourceGuid
99 DDDC8FDE-46CD-493F-8AB9-0570DECE9183
9 005E111E-B04B-44C8-B6FE-37FBC9547B8D
88 E6BB97E7-67AE-4DF5-BD44-C1612098B137
87 A0EE300B-C449-4E3A-9B82-7442F3AEDF11
8 9A73D013-D2BA-43DC-A213-EF8FC9789498
select [Count of Disk Errors], _ResourceGuid
from Inv_Hard_Disk_Errors
where _resourceguid in (select guid from vComputer where IsManaged = '1')
and try_cast([COUNT of Disk Errors] as int) > 250
order by try_cast([COUNT of Disk Errors] as int) desc
In Sql Server 2012 and up: each of these will return null
when the conversion fails instead of an error. 在Sql Server 2012及更高版本中:当转换失败而不是错误时,这些参数中的每一个都将返回null
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.