A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

MDB Queries



 
 
Thread Tools Display Modes
  #1  
Old February 28th, 2007, 12:26 AM posted to microsoft.public.access.queries
MUSIWA
external usenet poster
 
Posts: 3
Default MDB Queries

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


  #2  
Old February 28th, 2007, 03:16 AM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default MDB Queries

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" wrote:

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
1970 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

  #3  
Old February 28th, 2007, 07:03 PM posted to microsoft.public.access.queries
MUSIWA
external usenet poster
 
Posts: 3
Default MDB Queries

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!!

"Jerry Whittle" wrote:

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" wrote:

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
1970 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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:45 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.