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  

find all 5 fields with Max date



 
 
Thread Tools Display Modes
  #1  
Old June 27th, 2008, 09:58 PM posted to microsoft.public.access.queries
Mitchell_Collen via AccessMonster.com
external usenet poster
 
Posts: 58
Default find all 5 fields with Max date

Hi

I want to create a query that will return 5 fields that have the max date or
latest date. I can't get the following to work though.

Select Drug, Location, Total_On_hand, min, max, Datetime
From InMachine
Where Max(Datetime)

I don't have to show the Datetime, I just need to see in all 200 locations
and what drug and Totals on hand were for a quick snap shot.

Please help me.
Thanks.
Misty

--
Misty :-)

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

  #2  
Old June 28th, 2008, 12:20 AM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default find all 5 fields with Max date

Use two queries unless you know subqueries ---
Save this query as Last_Drug_Loc.
Select Drug, Location, Max([InMachine].[Datetime]) AS Last_Date
From InMachine
GROUP BY Drug, Location;

Select Drug, Location, Total_On_hand, min, max, Max([InMachine].[Datetime])
AS Last_Date
From InMachine INNER JOIN Last_Drug_Loc ON [InMachine].[Drug]=
Last_Drug_Loc.Drug AND [InMachine].[Location]= Last_Drug_Loc.Location AND
[InMachine].[Datetime]= Last_Drug_Loc.Last_Date
;
--
KARL DEWEY
Build a little - Test a little


"Mitchell_Collen via AccessMonster.com" wrote:

Hi

I want to create a query that will return 5 fields that have the max date or
latest date. I can't get the following to work though.

Select Drug, Location, Total_On_hand, min, max, Datetime
From InMachine
Where Max(Datetime)

I don't have to show the Datetime, I just need to see in all 200 locations
and what drug and Totals on hand were for a quick snap shot.

Please help me.
Thanks.
Misty

--
Misty :-)

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200806/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 11:21 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.