N
Nir N
I sm sorry for the complex question, but I don't have much experience in SQL.
I have to query an external database (meaning I cannot change it's design to
a more user friendly one).
The table consistst of patients visits to a clinic.
For each patient there are 3 fields: An ID, visit date and the examination
code the patient made in that date, so for every visit there are multiple
(20-30) records per patient, all with the same ID and date, some of them even
with the same exam ID (if the patient had multple X-Rays at the same day, for
example).
Usually patients are followed-up every year.
To make things more ocmplex, if the patient visited the clinic a few times
in a 2-months period, it is still considered one visit (some patients are
recalled to repaet an examination if the lab has technical problems or to
verify an abnormal lab test).
However, their exam dates wil be the actual dates that they visited (so an
exam dated March 15th 2008 and another exam dated May 1st 2008 are considered
as the same visit).
I need to write 2 queries:
1. A query that lists all patients (within a specific date range) that
visited the clinic only once in their lifetime (the query result should be
only one record per patient, regardless of how many exams he had at that
visit).
2. A complimentary query that lists all patients who visited the clinic more
than once (i.e. arrived for follow-up). This query shoudl result in one
record per visit.
Is is possible to code those 2 queries into an SQL or Access query?
Thanks,
Nir
I have to query an external database (meaning I cannot change it's design to
a more user friendly one).
The table consistst of patients visits to a clinic.
For each patient there are 3 fields: An ID, visit date and the examination
code the patient made in that date, so for every visit there are multiple
(20-30) records per patient, all with the same ID and date, some of them even
with the same exam ID (if the patient had multple X-Rays at the same day, for
example).
Usually patients are followed-up every year.
To make things more ocmplex, if the patient visited the clinic a few times
in a 2-months period, it is still considered one visit (some patients are
recalled to repaet an examination if the lab has technical problems or to
verify an abnormal lab test).
However, their exam dates wil be the actual dates that they visited (so an
exam dated March 15th 2008 and another exam dated May 1st 2008 are considered
as the same visit).
I need to write 2 queries:
1. A query that lists all patients (within a specific date range) that
visited the clinic only once in their lifetime (the query result should be
only one record per patient, regardless of how many exams he had at that
visit).
2. A complimentary query that lists all patients who visited the clinic more
than once (i.e. arrived for follow-up). This query shoudl result in one
record per visit.
Is is possible to code those 2 queries into an SQL or Access query?
Thanks,
Nir