Icon View Incident Report

Serious Serious
Reported By: James D. Duff
Reported On: 7/21/2001
For: Version 2.11 Build 1
# 822 Using 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 Comments and Workarounds
The 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.


Resolution Resolution
Fixed Problem on 7/22/2001 in version 2.12 build 1
Image