Roger's Access Library Homepage
Forum Home Forum Home > Roger's Access Library > Roger's Download Samples
  New Posts New Posts RSS Feed - SubQuery.mdb ( beginner )
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

>
Want a good read? Try The Summer of His Life (available on Amazon!)

SubQuery.mdb ( beginner )

 Post Reply Post Reply
Author
Message
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP


Joined: 20 Feb 2008
Status: Offline
Points: 261
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Topic: SubQuery.mdb ( beginner )
    Posted: 21 Jul 2008 at 10:43pm
 
Please consider donating $1 per sample downloaded, find out why here.
 
SubQuery.mdb
 
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.

Download
Access 97 (11 KB):
uploads/5/SubQuery97.zip
Access 2000 (18 KB): uploads/5/SubQuery2k.zip
Consider donating $1 per sample downloaded, find out why here.<
Back to Top
Sponsored Links
>
Want a good read? Try The Summer of His Life (available on Amazon!)

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.