I think this got a little bit too complex for me. My problem, very simplified:
I have the following tables:
Clients:
- ID
- Name
Events:
- ID
- ClientID
- Type (number, 1 or 2. 1 means question, 2 means answer)
- Date
The tables are related by ID - ClientID.
I want a query that lists all clients that have unanswered questions. I want to do it this way:
Compare the date of the last event type 1 (question) with the date of the last event type 2 (answer) for each client.
If the last answer date is earlier than the last question date, it means there are unanswered questions, and I want the client output in the query.
The query must also work if there are no events of one type or the other.
Anyone have suggestions, using query designer or sql?
- svesjo