K
kilkerr1
Hi all
Something I've been struggling with for a while:
I have 2 tables, tblClient and tblEpisode. Each client
(details such as client_forename and client_surname are
recorded in tblClient) may have one or more than one
contact episode (details such as episode_id,
episode_start_date and episode_dose are recorded in
tblEpisode). The relationship is a one-to-many and the
join is made by the client_id field.
I want to create a query which shows details of ONLY the
latest episode for every client. Fields I am trying to
return are:
- tblClient.client_forename
- tblClient.client_surname
- tblEpisode.episode_dose
- tblEpisode.episode_total_dose (this is a calulated
field: the user inputs how many days they want and the
episode_dose for each client is multiplied by this number
of days)
At the moment I am getting back details from all episodes
that a client may have had. I've tried using Group By
MAX function in the episode_start_date field, and the
Group By MAX function in the episode_id field (an
autonumber primary key for each episode which increases
for each episode added) but these still show ALL the
episodes for each client rather than just the latest
addedd. I guess it must be a bit more complicated than
that...
Please help - I'm getting desperate!
Thanks.
Something I've been struggling with for a while:
I have 2 tables, tblClient and tblEpisode. Each client
(details such as client_forename and client_surname are
recorded in tblClient) may have one or more than one
contact episode (details such as episode_id,
episode_start_date and episode_dose are recorded in
tblEpisode). The relationship is a one-to-many and the
join is made by the client_id field.
I want to create a query which shows details of ONLY the
latest episode for every client. Fields I am trying to
return are:
- tblClient.client_forename
- tblClient.client_surname
- tblEpisode.episode_dose
- tblEpisode.episode_total_dose (this is a calulated
field: the user inputs how many days they want and the
episode_dose for each client is multiplied by this number
of days)
At the moment I am getting back details from all episodes
that a client may have had. I've tried using Group By
MAX function in the episode_start_date field, and the
Group By MAX function in the episode_id field (an
autonumber primary key for each episode which increases
for each episode added) but these still show ALL the
episodes for each client rather than just the latest
addedd. I guess it must be a bit more complicated than
that...
Please help - I'm getting desperate!
Thanks.