Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2012, 12:24 PM
Authorized User
 
Join Date: May 2009
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default Maximum as a criterion in an Access Query

I need to query a table that contains results of surveys for various pieces of property. One of the fields will be number, beginning with 1, that indicated which survey this set of data represents. I will definitely at times want the data from the first survey and that is an easy query.

But what about when I was the last (highest number) query on a property? That is, for the survey number field, rather than putting in a number (because each property has a different nunber of surveys and I don't readily know how many surveys a given piece of property has had) I want to use the equivalent of MAX in Excel. That is, my criteria for that field is to find the record where that field has the largest value.

If I am not clear, I may have 7 entries for various surveys done over time for Property A. Then again, I may have only two surveys or as many as dozens. I know I could easily run a query to show me how many there are so I would no the highest number used for Property A, but that is a pain to do.

So the question is, can I just put Max or Maximum into the query criterion box for the SurveyNumber field and Property A in that field and get the survey results I am looking for, that is the results for the last survey entered?
 
Old March 2nd, 2012, 02:08 PM
Authorized User
 
Join Date: May 2009
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First, I should admit that I am not a SQL guy. I sort of understand it, but when I cannot use the Access Query interface, I need to go to books for how to adjust the SQL.

I believe I have discovered an easier way to do this. If I first to a sub query, use the property and survey fields (specifying the property and returning only the survey number in the result), I believe that all I need to do is set the survey number field in descending order and set the properties of the query to return the top one result. And then use this query as part of the basis for my later query to get the results of the needed survey for the specified property.

Anyone see any difficulties in that approach? If not, it is a fairly simple system to use.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Maximum as a criterion in an Access Query rmccafferty Excel VBA 1 March 2nd, 2012 12:26 PM
where clause/criterion sauloftarsus SQL Server 2005 0 November 23rd, 2011 04:15 AM
Update query doesnt run when Select query does (In MS Access) rmccafferty SQL Language 3 February 11th, 2010 04:54 AM
Row Maximum bmains SQL Server 2000 2 October 7th, 2004 08:39 PM
Finding the maximum and using it outside the IF jrwarwick XSLT 2 October 17th, 2003 03:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.