我正在使用以下代码。它工作正常,但当我使用日期过滤器时,它停止工作。我在sql中使用了比较运算符。我搜索了一些问题,但没有找到理想的答案。
SELECT SUM(retailerData.poster), SUM(retailerData.banners), SUM(retailerData.tradeLetters), SUM(retailerData.stickers) ,
SUM(retailerData.buntings),SUM(retailerData.dangler) FROM retailerData INNER
JOIN retailer ON retailer.retailerID=retailerData.retailerID WHERE
'2016-08- 24'<= retailerData.visitDate <='2016-09-03'
AND retailer.retailerID IN( SELECT
retailer.retailerID FROM retailer INNER JOIN office ON office.officeID=
retailer.officeID WHERE office.officeID IN( SELECT officeID FROM office
WHERE
parentOfficeID IN( SELECT officeID FROM office WHERE parentOfficeID IN
(SELECT
officeID FROM office WHERE officeName='Faisalabad Belt') ) ))
帮我解决这个问题。
答案 0 :(得分:5)
你有这个条件:
WHERE '2016-08- 24'<= retailerData.visitDate <= '2016-09-03'
在大多数方言中,这不是标准的 - 既不是三元运算符也不是日期文字中的空格。
试试这个:
WHERE '2016-08-24'<= retailerData.visitDate AND
retailerData.visitDate <= '2016-09-03'