SubQuery.mdb ( beginner ) |
Post Reply |
Author | |
Roger Carlson
Microsoft MVP Joined: 20 Feb 2008 Status: Offline Points: 261 |
Post Options
Thanks(0)
Posted: 21 Jul 2008 at 10:43pm |
Please consider donating $1 per sample downloaded, find out why here.
The question is, how do you write a query which find the maximum value of a given group, but then returns all of the values associated with that record? A simple Totals query won't do it. If you try to add other fields, it will group on those as well. If you use some other function like FIRST, you will get just the first value of the other field it can find, not the value that is associated with the value returned with MAX.
The solution is to use a subquery. In a sub query, you return a list of values to the main query which you can evaluate in the WHERE clause with the IN operator. |
|
|
|
Sponsored Links | Want a good read? Try The Summer of His Life (available on Amazon!) |
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |