Hi,
I have a table (or query) with the following fields
Code:
USER_ID
CODE (can be "A" or "B")
DATUM (dutch for "date")
REF_DATE
REF_EXPLICATION
Each record HAS data for the first 3 fields; the other fields CAN have data. (of course, each user and each code is linked to a separate table with name, etc...)
Now, I want to build a query that shows me the records (with user_id, code_id, ref_explication)...
1) where CODE = "A" and there's no record where the CODE = "B AND where DATE is equal to REF_DATE of the record with code = “A"
or
2) where CODE = "A" and there's no REF_DATE
or
3) where CODE = "B" and there's no REF_DATE
Giving the sample database included, I would like to have this result :
Code:
USER_ID CODE_ID - DATE - REF_EXPLICATION_1 - REF_DATE - REF_EXPLICATION_2
1 A 07/08/2013 01/01/2014 phonecall (*)
1 A 08/08/2013 (**)
1 B 10/08/2013 (***)
(*) because there's no matching record with code=B AND date=ref_date
(**) because code=A and there's no ref_date
(**) because code=B and there's no ref_date
Can someone help me or give me some suggestions?
I also split the table in records with code= "A" and in records with code = "B". (see queries) Maybe this can help ?