MDB Queries

M

MUSIWA

I have a query that shows the visits of my contacts. I would like to filter
it so that only one visit per contactID shows and is the most recent visit.
right now all the visits of each contact show eg Contactid 1970 visitdate
02/14/2006
1970
03/14/2006
1970
04/14/2006

What I would like is just one contactid and just the most recent visit for
each contact
contactid 1970 visit date o4/14/2006. I have over
1000 visits in the query
 
J

Jerry Whittle

SELECT contactID, Max(visitdate)
FROM Contacts
GROUP BY contactID
ORDER BY contactID ;

This will only work if the visitdate field is an actual Date/Time field.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

MUSIWA said:
I have a query that shows the visits of my contacts. I would like to filter
it so that only one visit per contactID shows and is the most recent visit.
right now all the visits of each contact show eg
Contactid visitdate
 
M

MUSIWA

Thanks Jerry it worked very well. I was able to save the query and then add
other variables on it using joins with other tables. Well Done SIR!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top