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  

Last records from a Group By query



 
 
Thread Tools Display Modes
  #1  
Old February 20th, 2010, 04:15 AM posted to microsoft.public.access.queries
KevinE via AccessMonster.com
external usenet poster
 
Posts: 3
Default Last records from a Group By query

I would like to write a query to find the last (most recent date) records
only from two different fields. No problems using MAX in the ‘Date’ field,
the problem being with the ‘Player’ field. I’ve tried using LAST but it seems
to throw up incorrect results.

thanks,
Kevin

SELECT tblMain.Team, Last(tblMain.Player) AS LastOfPlayer, Max(tblMain.Date)
AS MaxOfDate
FROM tblMain RIGHT JOIN tblCurrent ON tblMain.Team = tblCurrent.Team
GROUP BY tblMain.Team, tblCurrent.ID
ORDER BY tblCurrent.ID;

--
Message posted via http://www.accessmonster.com

  #2  
Old February 20th, 2010, 08:54 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default Last records from a Group By query

See if this helps:
Getting a related field from a GroupBy (total) queryat:
http://www.mvps.org/access/queries/qry0020.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"KevinE via AccessMonster.com" u19948@uwe wrote in message
news:a3e5d8ac52fa7@uwe...
I would like to write a query to find the last (most recent date) records
only from two different fields. No problems using MAX in the ‘Date’ field,
the problem being with the ‘Player’ field. I’ve tried using LAST but it
seems
to throw up incorrect results.

thanks,
Kevin

SELECT tblMain.Team, Last(tblMain.Player) AS LastOfPlayer,
Max(tblMain.Date)
AS MaxOfDate
FROM tblMain RIGHT JOIN tblCurrent ON tblMain.Team = tblCurrent.Team
GROUP BY tblMain.Team, tblCurrent.ID
ORDER BY tblCurrent.ID;

--
Message posted via http://www.accessmonster.com

 




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 03:05 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.