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  

Qry with dupes looking for only most recent date



 
 
Thread Tools Display Modes
  #1  
Old February 18th, 2010, 03:58 PM posted to microsoft.public.access.queries
The Joker via AccessMonster.com
external usenet poster
 
Posts: 12
Default Qry with dupes looking for only most recent date

Hello all,

I have a query I'm running and when it pulls it has a bunch of duplicates,
which is expected. Is there some type of criteria or something I can do to
only pull the most recent occurence of each result? Thank you!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201002/1

  #2  
Old February 18th, 2010, 04:35 PM posted to microsoft.public.access.queries
vanderghast
external usenet poster
 
Posts: 593
Default Qry with dupes looking for only most recent date

Four ways to do it at http://www.mvps.org/access/queries/qry0020.htm


Vanderghast, Access MVP


"The Joker via AccessMonster.com" u17775@uwe wrote in message
news:a3d2d69829281@uwe...
Hello all,

I have a query I'm running and when it pulls it has a bunch of duplicates,
which is expected. Is there some type of criteria or something I can do
to
only pull the most recent occurence of each result? Thank you!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201002/1


  #3  
Old February 18th, 2010, 04:54 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Qry with dupes looking for only most recent date

The Joker -

If you post your SQL it would be easier for us to help.

There are two ways to do this, depending on what data you are pulling.
First case is a simple query with only key values and the date field:

Select EmployeeID, EmployeeName, ActionDate from EmployeeActionTable;

Change to this:

Select EmployeeID, EmployeeName, Max(ActionDate) from EmployeeActionTable;


The more complex situation is where you have multiple fields you want to see
that are different between the records, but you only want the latest-dated
record. These cases need a sub-query, or multiple Access queries. For
example:

Select EmployeeID, EmployeeName, ActionDate, ActionDescription,
ActionField2, ActionField3 from EmployeeActionTable;

Change to this:

Select EmployeeID, EmployeeName, ActionDate, ActionDescription,
ActionField2, ActionField3 from EmployeeActionTable
WHERE ActionDate = (SELECT Max(ActionDate) FROM EmployeeActionTable AS EA
WHERE EA.EmployeeID = EmployeeActionTable.EmployeeID);

It can get much more complex with joined tables...

If you need more help, you need to post your SQL and maybe a sample of the
duplicates you are getting.

--
Daryl S


"The Joker via AccessMonster.com" wrote:

Hello all,

I have a query I'm running and when it pulls it has a bunch of duplicates,
which is expected. Is there some type of criteria or something I can do to
only pull the most recent occurence of each result? Thank you!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201002/1

.

 




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 06:08 AM.


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