×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

(OP)
I have 2 tables with a 1 to many join and the key id is the join. The many table has a date and I would only like the record with the most recent date to be joined if there are more than one. I built a query where the date field criteria is max([date field]). That field could be Null but I am not checking for that, could that be the issue?
Appreciate any assistance!

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

Make a query that groups by Key ID and gets the max of the date.

Then inner join that query to limit the results.

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

(OP)
Are you saying for the table that has multiple dates, make a query for it and group by ID and then do a max for date - then join the other table for it? Regardless I am having trouble with the syntax for the Max.

I tried max([date field]) within that field in the query criteria
Thanks

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

Quote (08211987)

I built a query where the date field criteria is max([date field]).

Show the whole query here. It will be easier to help you.


---- Andy

There is a great need for a sarcasm font.

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

(OP)
I wish I could but I can't send emails to my home from work. I tried what Lameid said above to group the table that has the multiple recs by ID and then the max of the date "Max([Table2.Date]) in criteria and it only brings back 2 records, there are 1000's.

Then I tried where I have table1 where the key is on another table and I want some data from Table2 where the keys are equal but I only want the information from table2 where the date is the newest but it is still bring in all dub records with the key field.

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

Change your query to SQL view and copy and paste the SQL statement here.

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

(OP)
Hi thanks, I now think it is working thanks! I'll find out at work on Monday with new data!

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

(OP)
Somehow I managed to get the Max to work to give me results I was looking for I'm just not sure how to get the Join that I need.

I now have the results of 2 fields containing ID and 1 date representing the max date in a separate file called "Max Table". Some of the IDs do not have a date. I have the original file that has duplicate IDs but different dates or no dates called "Table1". How would I create a query(s) that would join "Table1" to "Max Table" and append to a new "Table2" Providing no duplicate IDs and contain the max date I saw in "Max Table" with all the other fields?

Appreciate your help! Thank you.

RE: Join 2 tables on key id with 1 to many, bring back the newest date value on the many side

(OP)
I believe I have resolved this one as well, I'll find out when I use my real data on Monday. Thanks!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close