473,785 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query Max values in repeating data

I am Access newbie looking for some guidance in putting together a
query that can output a table of max values in a given column grouped
by a couple of other columns. Here is an example of what I need the
query to do.

Existing Data
Table:Z
A B C D E
1 1 1 7 12
1 1 2 6 43
1 1 3 3 22
1 2 1 4 2
1 2 2 3 123
1 2 3 4 27
2 1 1 5 13
2 1 2 6 6
2 1 3 6 312
2 2 1 3 27
2 2 2 8 27
2 2 3 9 4

Query Result
Table:Y
A B C D E
1 1 2 6 43
1 2 2 3 123
2 1 3 6 312
2 2 2 8 27

I need to find the maximum value in column E grouped by columns A and
B. In the case of a tie in column E, the row with the largest value in
column C should be selected. Any help would be much appreciated.

Thanks in advance,
Brent

Nov 16 '06 #1
2 3030
Create a totals query:

Group By [A], [b]
Max [E]

Join this query to the original table via all three fields [A], [b], and [E].
Output all of the fields.
If there is a tie, make a totals query on the preceding query:

Group By [A], [b], [E]
Max [C]

Then join this query to the original table via all four fields and output all
five fields. HTH

brob wrote:
>I am Access newbie looking for some guidance in putting together a
query that can output a table of max values in a given column grouped
by a couple of other columns. Here is an example of what I need the
query to do.

Existing Data
Table:Z
A B C D E
1 1 1 7 12
1 1 2 6 43
1 1 3 3 22
1 2 1 4 2
1 2 2 3 123
1 2 3 4 27
2 1 1 5 13
2 1 2 6 6
2 1 3 6 312
2 2 1 3 27
2 2 2 8 27
2 2 3 9 4

Query Result
Table:Y
A B C D E
1 1 2 6 43
1 2 2 3 123
2 1 3 6 312
2 2 2 8 27

I need to find the maximum value in column E grouped by columns A and
B. In the case of a tie in column E, the row with the largest value in
column C should be selected. Any help would be much appreciated.

Thanks in advance,
Brent
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200611/1

Nov 16 '06 #2
Thanks HTH, your solution worked perfectly.
kingston via AccessMonster.c om wrote:
Create a totals query:

Group By [A], [b]
Max [E]

Join this query to the original table via all three fields [A], [b], and [E].
Output all of the fields.
If there is a tie, make a totals query on the preceding query:

Group By [A], [b], [E]
Max [C]

Then join this query to the original table via all four fields and output all
five fields. HTH

brob wrote:
I am Access newbie looking for some guidance in putting together a
query that can output a table of max values in a given column grouped
by a couple of other columns. Here is an example of what I need the
query to do.

Existing Data
Table:Z
A B C D E
1 1 1 7 12
1 1 2 6 43
1 1 3 3 22
1 2 1 4 2
1 2 2 3 123
1 2 3 4 27
2 1 1 5 13
2 1 2 6 6
2 1 3 6 312
2 2 1 3 27
2 2 2 8 27
2 2 3 9 4

Query Result
Table:Y
A B C D E
1 1 2 6 43
1 2 2 3 123
2 1 3 6 312
2 2 2 8 27

I need to find the maximum value in column E grouped by columns A and
B. In the case of a tie in column E, the row with the largest value in
column C should be selected. Any help would be much appreciated.

Thanks in advance,
Brent

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200611/1
Nov 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
2735
by: Wescotte | last post by:
Here is a small sample program I wrote in PHP (running off Apache 1.3.31 w/ PHP 5.0.1) to help illustrates problem I'm having. The data base is using DB2 V5R3M0. The client is WinXP machine using the iSeries Client Access Driver ver 10.00.04.00 to connect to the database. The problem is that executing the exact same SQL select statement more than twice int a row stops produces results. The first two instances will always produce the...
2
926
by: Stan | last post by:
Hello all, I'm looking for some hints as to how to use the results of a query in another query. I assume I'm 'thinking' wrong in how to solve this, so I'm hoping someone can clobber me and send me in the right direction. My question is best illustrated by simplified example. I have one table (table A) with a single column called "Word". This table contains 100 records of single words. Another table (table B) contains whole sentences...
2
12236
by: kj | last post by:
Here is tested schema if exists (select * from dbo.sysobjects where id = object_id(N'.') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table . GO CREATE TABLE . ( (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
3
3303
by: MLH | last post by:
Am repeating question with different subject heading, perhaps stating more clearly my problem... I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string values in it like... Between #12/1/2004# And #12/31/2004# - or - >= #6/10/2005# - or -
5
1745
by: jim Bob | last post by:
Hi, Can someone help with a simple query? I have a table with the following. Firstname Lastname InterviewerID1 InterviewerID2 InterviewerID3 ...
9
2052
by: jardar.maatje | last post by:
I am logging scientific data. For this a normal relationship database is not idéal but I am going to try it. I have basically three tables like: datarecord: * idx - integer * time - datetime * type - integer
6
2496
by: dejavue82 | last post by:
This is the result of a JOINed query: question answer 1 a1 1 a2 1 a3 1 a4 2 a1 2 a2
1
1693
by: redskycorp | last post by:
I have repeating values in my combo box, i do want the values to repeat...any idea how to do that ? The reason is that i am taking the values from my database table "Incomplete" from the "Topic" column....The values repeats it self cause it shows all the values in the column including repeating ones....Anyone know what to do ? I have also included my codings...... Dim data As DAO.Database Dim rec As DAO.Recordset Private Sub Form_Load()...
4
13723
by: Yitzak | last post by:
Have a query that is arregated into crosstab query, it is working correctly. select Yes as selected from tblname or select true as selected from tblname Produces -1 ( vba value of True) in the results pane I would like to see it produce a checkbox with tick in just like I would see if I displayed a boolean/yes/no field from a table.
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.