正如标题所说,当我使用sql之间的子句时,我正在针对从低到高的地址范围运行它,并且我输入的数字超出了两个并且让行返回给我。我想知道为什么。
http://www.sqlfiddle.com/#!6/49467/2
快速点击查询,我使用的地址编号为4929
并将行返回给我,其中地址范围为低和高数字分别为400
和498
。
以下是查询:
SELECT
ZipCodeLow ,
ZipCodeHigh ,
ZipExtensionLow ,
EndingEffectiveDate ,
BeginningEffectiveDate ,
AddressRangeLow ,
AddressRangeHigh ,
StreetName ,
City ,
ZipCode ,
Zip4,
Zip4High
FROM BoundTable
WHERE
('68503' BETWEEN ZipCodeLow AND ZipCodeHigh) AND
('4929' BETWEEN [AddressRangeLow] AND [AddressRangeHigh]) AND
([StreetName] = '32ND') AND
(GETDATE() BETWEEN [BeginningEffectiveDate] AND [EndingEffectiveDate])
答案 0 :(得分:2)
首先将4929转换为数字,然后运行查询:
SELECT
ZipCodeLow ,
ZipCodeHigh ,
ZipExtensionLow ,
EndingEffectiveDate ,
BeginningEffectiveDate ,
AddressRangeLow ,
AddressRangeHigh ,
StreetName ,
City ,
ZipCode ,
Zip4,
Zip4High
FROM BoundTable
WHERE
('68503' BETWEEN ZipCodeLow AND ZipCodeHigh) AND
(convert(numeric,'4929') BETWEEN [AddressRangeLow] AND [AddressRangeHigh]) AND
([StreetName] = '32ND') AND
(GETDATE() BETWEEN [BeginningEffectiveDate] AND [EndingEffectiveDate])