473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

aggregate query

13
I'm trying to create a query that finds the max of a group of records and then displays all details about that record. Suppose this is my data:

Type Size Color Quantity
A L Green 5
A M Blue 7
B S Orange 2
B M Red 4
B L Purple 5
C M Red 10
C L Green 12

How can I get output as
Results:
Type Size Color Quantity
A M Blue 7
B L Purple 5
C L Green 12

I can get the max items with my one sort field ok, but if I want to add more fields it starts grouping them and making duplicates.

Any suggestions,

thanks
Mar 27 '07 #1
3 1458
Rabbit
12,516 Expert Mod 8TB
Will there be any duplicate colors at the Type level?

Is there some sort of primary key?
Mar 28 '07 #2
brent78
13
Will there be any duplicate colors at the Type level?

Is there some sort of primary key?
Yes, there can be duplicate colors and there is a primary key as shirt_id
Mar 28 '07 #3
Rabbit
12,516 Expert Mod 8TB
Yes, there can be duplicate colors and there is a primary key as shirt_id
Put this in the criteria for shirt_id:
Expand|Select|Wrap|Line Numbers
  1. (SELECT TOP 1 shirt_id FROM [Table Name] WHERE Type = x.Type ORDER BY DESCENDING Quantity;)
You'll also have to give the table an alias of "x".
Mar 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Greg Stark | last post by:
I find I often want to be able to do joins against views where the view are aggregates on a column that has an index. Ie, something like SELECT a.*, v.n FROM a JOIN (select a_id,count(*) as n...
2
by: Toby Dann | last post by:
I have an aggregate query as recordsource for a form to show a list of invoices, including the totals (calculated by the aggregate query - I'm trying to duplicate as little info as possible here)....
1
by: sausage31 | last post by:
I have a table as follows.... Device LotID Result1 Result2 Result3 aaa 1 5 10 15 bbb 1 2 4 6 aaa 2 ...
5
by: Jim | last post by:
Need help with aggregate function...for each unique product, I need the provider with the cheapest cost factor Here't the table (Table1) ID product provider factor 1 123456 abc...
3
by: eddiec | last post by:
hi everyone, I have a report in an adp that uses aggregate functions in its record source and I am trying to figure out how to filter the records displayed in the report: DoCmd.OpenReport...
10
by: neb | last post by:
Dear member of the forum, Ms access has built-in aggregate function like: -Sum, Max, First, Avg, ... Is it possible to build user-defined aggregate? (if you have any clue, do not hesitate to...
1
by: Scott Gerhardt | last post by:
Hello, I am new to the list, my apology if this question is beyond the scope or charter of this list. My questions is: What is the best method to perform an aggregate query to calculate sum()...
0
by: BillCo | last post by:
just wasted a long time figuring out this and I figure if I post it might save someone some pain! Jet (DAO) will allow you to to use nested aggregate functions like building blocks, e.g.: ...
5
by: BillCo | last post by:
I just wasted a long time figuring out this and I figure if I post it might save someone some pain! Jet (DAO) will allow you to to use nested aggregate functions like building blocks, e.g.: ...
4
by: wrldruler | last post by:
Hello, First, I know it's against "Access Law" to save calculations in a table, but....I want/need to. I currently have sub-totals being calculated inside a form, using DMax, DCount, and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.