Print Page | Close Window

SubQuery.mdb ( beginner )

Printed From: Roger's Access Library
Category: Roger's Access Library
Forum Name: Roger's Download Samples
Forum Description: A compendium of Microsoft Access 97 and 2000+ routines, each separated into its own sample database.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=260
Printed Date: 16 Apr 2024 at 3:55pm
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: SubQuery.mdb ( beginner )
Posted By: Roger Carlson
Subject: SubQuery.mdb ( beginner )
Date Posted: 21 Jul 2008 at 10:43pm
 
Please consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm - 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):
http://www.rogersaccesslibrary.com/forum/uploads/5/SubQuery97.zip - uploads/5/SubQuery97.zip
Access 2000 (18 KB): http://www.rogersaccesslibrary.com/forum/uploads/5/SubQuery2k.zip - uploads/5/SubQuery2k.zip


-------------
Consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm" rel="nofollow - find out why here .<



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net