Icon View Incident Report

Serious Serious
Reported By: Yavuz
Reported On: 1/31/2002
For: Version 3.04 Build 1
# 1017 Using Multiple AND and OR Conditions in a LEFT OUTER JOIN Causes Incorrect Results

I have an query and an incorrect result. Details below:

Table1 : DATES
--------------
DATE DATE
-----------
30.01.2002
31.01.2002
01.02.2002

Table2 : RECS
--------------
DATE1   DATE
DATE2   DATE
AMOUNT  INTEGER
----------------
30.01.2002  30.01.2002  1
30.01.2002  01.02.2002 2


SQL:
select A.DATE,sum(B.AMOUNT) as TOTAL_AMOUNT
from DATES A

left outer join RECS B ON
(
    (B.DATE1=B.DATE2)  and (A.DATE=B.DATE1)
)
group by A.DATE


RESULT
--------------
30.01.2002    1
31.01.2002
01.02.2002

Also I run below sql :
select A.DATE,sum(B.AMOUNT) as TOTAL_AMOUNT
from DATES A

left outer join RECS B ON
(
    (B.DATE1<B.DATE2)  and  (A.DATE>=B.DATE1) and  (A.DATE<B.DATE2)
)
group by A.DATE

RESULT
--------------
30.01.2002    2
31.01.2002    2
01.02.2002


and last, I run below sql too :

select A.DATE,sum(B.AMOUNT) as TOTAL_AMOUNT
from DATES A

left outer join RECS B ON
(
  (
    (B.DATE1=B.DATE2)  and (A.DATE=B.DATE1)
  )
 or
  (
    (B.DATE1<B.DATE2)  and  (A.DATE>=B.DATE1) and  (A.DATE<B.DATE2)
  )
)
group by A.DATE


RESULT         expected
-------------- ---------
30.01.2002   2 3
31.01.2002   2
01.02.2002

This result is incorect.



Comments Comments
Internally DBISAM is performing an AND instead of an OR. This problem only affects LEFT OUTER JOINs and does not cause a problem with regular INNER JOINs. We are investigating a solution for a future version.


Resolution Resolution
Scheduled for Future Release on in version 0.00 build 1
Image