Reported By: James D. Duff Reported On: 7/21/2001 For: Version 2.11 Build 1
# 822Using a Non-Equality (>, >=, <, <=) Operator with INNER JOINs Causes Incorrect Results in SQL Query The following SQL query does not compare the dates properly.
Select
Stock.StockID,
Rego,
Make,
Model,
PurchaseCost,
DatePurchased,
DateSold,
StockOnHandDate,
sum(Cost.Amount) TotalRecondCosts
from Stock, Cost, ProgramSettings
where
Stock.StockID = Cost.StockID
and DatePurchased < StockOnHandDate
group by
Stock.StockID
Comments and WorkaroundsThe problem was caused by the join re-ordering, which wasn't taking into account the non-equality operators correctly. The workaround to fix this problem is to use a NOJOINOPTIMIZE clause at the end of the query statement.
ResolutionFixed Problem on 7/22/2001 in version 2.12 build 1