How do I select the last record of a group in MS Access

I have 2 tables.  The 1st is system and the second is actions.  The relationship is multiple records from the actions table for every record in the system table.  I want to run a query selecting all the data from the system table and only the last action from the action table.  I have a date field in the action table.  Is this possible? How can I do this?

Marilyn
Marilync1266Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

swedishtongueCommented:
if you have unique identifier for action table then set the "total" to Max
0
calpurniaCommented:
Hi Marilyn, you don't say much about the structure of your tables, so I'm making the following assumptions:

You have 2 tables called tblSystems and tblActions.

tblSystems has a primary key called SystemID.

tblActions has a date field called ActionDate, and a SystemID field

Alter the field and table names in the following SQL statement to match your database.

SELECT A.*,  S.* FROM tblActions A, tblSystems S
WHERE A.ActionDate IN (SELECT Max(A2.ActionDate) FROM tblActions A2 WHERE A2.SystemID=A.SystemID)
AND A.SystemID=S.SystemID;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.