D
Dorian
I have 2 tables, a CASE table and an INVESTIGATOR table.
This is a one-to many relationship. Each Investigator has an Assign Date and
a Completion Date.
There may be zero, one or many investigators per case but only one at a time.
Completion dates could be missing:
Investigator1 Assigned 12/10/09 Completed 12/10/09
Investigator2 Assigned 12/10/09 Completed null
Assigned dates could be the same e.g.
Investigator1 Assigned 12/10/09 Completed 12/10/09
Investigator2 Assigned 12/10/09 Completed 12/11/09
Or, different e.g.
Investigator1 Assigned 12/10/09 Completed 12/11/09
Investigator2 Assigned 12/11/09 Completed 12/11/09
This is theoretically possible, in which case either record could be
returned:
Investigator1 Assigned 12/10/09 Completed 12/10/09
Investigator2 Assigned 12/10/09 Completed 12/10/09
I am trying to come up with a LatestInvestigator query that I can join to
the Case table.
The rule is I need the latest completion date (null being later than any
date) or if all completion dates are the same, the latest assign date or if
all assign/completion dates are the same, any one record.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
This is a one-to many relationship. Each Investigator has an Assign Date and
a Completion Date.
There may be zero, one or many investigators per case but only one at a time.
Completion dates could be missing:
Investigator1 Assigned 12/10/09 Completed 12/10/09
Investigator2 Assigned 12/10/09 Completed null
Assigned dates could be the same e.g.
Investigator1 Assigned 12/10/09 Completed 12/10/09
Investigator2 Assigned 12/10/09 Completed 12/11/09
Or, different e.g.
Investigator1 Assigned 12/10/09 Completed 12/11/09
Investigator2 Assigned 12/11/09 Completed 12/11/09
This is theoretically possible, in which case either record could be
returned:
Investigator1 Assigned 12/10/09 Completed 12/10/09
Investigator2 Assigned 12/10/09 Completed 12/10/09
I am trying to come up with a LatestInvestigator query that I can join to
the Case table.
The rule is I need the latest completion date (null being later than any
date) or if all completion dates are the same, the latest assign date or if
all assign/completion dates are the same, any one record.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".