By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Question on selecting dates in a query

P: 1
I am an infrequent user and my version is Access 2000. I have a list of 122k lines which consits of 3 fields/data points;a product code, a date, and a price code. I want to run a query to select the latest date the product code was entered and return the price code associated with the date. There are entrys for many different dates, none of them are the same. I have pulled all the data into access but can not figure out how to get just the latest or greatest date with its associated code.
Nov 22 '06 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
I am an infrequent user and my version is Access 2000. I have a list of 122k lines which consits of 3 fields/data points;a product code, a date, and a price code. I want to run a query to select the latest date the product code was entered and return the price code associated with the date. There are entrys for many different dates, none of them are the same. I have pulled all the data into access but can not figure out how to get just the latest or greatest date with its associated code.
this should do it ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT [Product code], Max([Date]) As LatestDate, DLookup("[Price code]", "TableName", "[Date]=" & LatestDate & " And [Product code]=" & [Product code]) As PriceCode
  3. FROM TableName
  4. GROUP BY [Product code];
  5.  
Nov 23 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.