SQL选择nvarchar列的范围

时间:2014-05-05 04:03:48

标签: sql sql-server

如何从范围为55 - 42000的column_a中选择表格。

注意:column_a的数据类型位于nvarchar

我试过这样,但没有运气

SELECT 
   SoftwareName, SoftwareImageTeaser, SoftwarePrice, SoftwareDescription
FROM 
   View_Software_Listing_With_Category 
WHERE 
   (SoftwarePrice >= '55' AND SoftwarePrice <= '42000')

2 个答案:

答案 0 :(得分:2)

SELECT SoftwareName,SoftwareImageTeaser,SoftwarePrice,SoftwareDescription
FROM View_Software_Listing_With_Category 
WHERE (CAST(CAST(SoftwarePrice AS FLOAT) AS INT) BETWEEN 55 AND 42000

答案 1 :(得分:1)

试试这个,因为你的SoftwarePrice列是nvarchar,你需要在整数中转换它以与整数值进行比较。然后,您可以使用between子句来过滤记录。

SELECT SoftwareName,SoftwareImageTeaser,SoftwarePrice,SoftwareDescription
FROM View_Software_Listing_With_Category 
WHERE Cast(SoftwarePrice as Int) between 55 AND 42000