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  dBforums > PC based Database Applications > Microsoft Access > Access 2010 Earliest Date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-13-12, 14:03
access2010user access2010user is offline
Registered User
 
Join Date: Jul 2012
Posts: 11
Access 2010 Earliest Date

I need to find the earliest date that each product was received at each store in my retail chain.

I have a receiving table, and a product table

The fields in each table are:

PRODUCT TABLE
product_number
product_name

RECEIVING TABLE
product_number
store_number
receiving_date

...the product_number field is common between the two tables and can be joined.



Can anyone help? Thank you!
Reply With Quote
  #2 (permalink)  
Old 07-13-12, 14:28
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,658
You may need just the first query, adapted to your 2 fields to group on:

Most recent value
__________________
Paul
Reply With Quote
  #3 (permalink)  
Old 07-13-12, 14:38
access2010user access2010user is offline
Registered User
 
Join Date: Jul 2012
Posts: 11
Thank you....I feel like I tried this....

SELECT articles.article, Min([purch]![ym_pu]) AS Expr1
FROM articles INNER JOIN purch ON articles.article = purch.art_pu;

but I am getting this error

'You tried to execute a query that does not include the specified expression 'article' as part of an aggregate function.'

articles is the product table
article is the product name in the product table

purch is the receiving table
art_pu is the product name in the product table
ym_pu is the receiving date in the product table

What am I missing in the query code?
Reply With Quote
  #4 (permalink)  
Old 07-13-12, 15:19
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,658
You missed the GROUP BY clause. Try

SELECT articles.article, Min([purch]![ym_pu]) AS Expr1
FROM articles INNER JOIN purch ON articles.article = purch.art_pu;
GROUP BY articles.article
__________________
Paul
Reply With Quote
  #5 (permalink)  
Old 07-13-12, 15:24
access2010user access2010user is offline
Registered User
 
Join Date: Jul 2012
Posts: 11
Here is what I have

SELECT articles.article, Min([purch]![ym_pu]) AS Expr1
FROM articles INNER JOIN purch ON articles.article = purch.art_pu;
GROUP BY articles.article

but I received the following error

'The LEVEL clause includes a reserved word or argument that is mispelled or missing , or the punctuation is incorrect.'

I have no clue what that means.
Reply With Quote
  #6 (permalink)  
Old 07-13-12, 15:28
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,658
My bad, missed the semi-colon:

SELECT articles.article, Min([purch]![ym_pu]) AS Expr1
FROM articles INNER JOIN purch ON articles.article = purch.art_pu
GROUP BY articles.article
__________________
Paul
Reply With Quote
  #7 (permalink)  
Old 07-13-12, 15:36
access2010user access2010user is offline
Registered User
 
Join Date: Jul 2012
Posts: 11
Perfect! You solved this perfectly!
Reply With Quote
  #8 (permalink)  
Old 07-13-12, 15:37
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,658
Happy to help!
__________________
Paul
Reply With Quote
  #9 (permalink)  
Old 07-13-12, 16:55
access2010user access2010user is offline
Registered User
 
Join Date: Jul 2012
Posts: 11
Thank you so very much. You really helped me get a project done!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On