Icon View Incident Report

Serious Serious
Reported By: Rene Lobsiger
Reported On: 12/23/2004
For: Version 4.15 Build 1
# 1929 SQL Joins in the WHERE Clause with Constant Expressions Can Cause Incorrect Results

I have a difference in the result of a sql - query. I think in 4.15 is something wrong. See below for the queries.

SELECT Temp2.prozent as ansatz
FROM Temp2 INNER JOIN BV ON (BV.BKst=Temp2.kstktr) 
WHERE BV.monat+BV.jahr*12 BETWEEN Temp2.begPeriod AND Temp2.endPeriod;

Returns in version 4.15 and 4.14 1413 records

SELECT Temp2.prozent as ansatz
FROM Temp2 INNER JOIN BV ON (BV.BKst=Temp2.kstktr) 
WHERE BV.monat+BV.jahr*12 >= Temp2.begPeriod AND
BV.monat+BV.jahr*12 <= Temp2.endPeriod;

Returns in version 4.15 9891 records and 4.14 1413 records



Comments Comments and Workarounds
The problem was the constant '12' in the join expression. It was being evaluated once and then applied to all join conditions when it should be evaluated for every row individually.


Resolution Resolution
Fixed Problem on 12/24/2004 in version 4.16 build 1
Image