Solved

Use of MAX function in MS Access Query

Posted on 2010-11-18
3
332 Views
Last Modified: 2012-05-10
I have an MS Access table that contains two columns that looks something like :

Field A        Field B
Houses       1
Houses       2
Houses       3
Houses       4
Houses       5
Flats            1
Flats             2
Flats             3
Flats             4
Bungalows   1
Bungalows   2
Bungalows   3

I want to run a query that returns only the rows where the highest number in Field B relates to Houses, Flats, or Bungalows.  i.e. the query will return 3 rows which will contain Version 5, 4 and 3 respectively.  My real data contains an inconsistent number of versions for each category, and I just want the 'Max' (highest number) in each case and return a single row

How do I create my query please?  I would like this in Design View syntax not SQL please
0
Comment
Question by:MPWOOD
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
MINDSUPERB earned 500 total points
ID: 34163510
See the screenshot attached for the Design View.

Sincerely,
Ed
Max.JPG
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 34163526
Here's the SQL Statement:

SELECT Table4.FieldA, Max(Table4.FieldB) AS MaxOfFieldB1
FROM Table4
GROUP BY Table4.FieldA;

And see screenshot when you run Query 3.

Sincerely,
Ed
Display.JPG
0
 

Author Closing Comment

by:MPWOOD
ID: 34163569
yes, it was so simple in the end !  I am so rusty on Access, I should've known that!  Thanks for your quick help.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question