Query Question

I

Ivar

Hi All.

First Time Asking Here :)
Looking for the SQL for a query on a simple table
Table has 3 fields, all Integer with a number between 1 and 10000
All fields can have duplicates, however: The combination of numbers in
fields 1 and 2 will always be unique.

I am looking for a query that will return unique values of field 1 with the
highest value of field 2.
So if my table contained this:
1 1 1
1 2 3
1 4 6
2 1 3
3 1 3
3 3 3
3 4 1
2 6 2
2 5 2
2 3 7
The Query would return:
1 4 6
2 6 2
3 4 1

Any ideas on the SQL for this, I'm stuck on this one.
Any help would be appreciated.

Ivar
 
B

Bob Barrows

Ivar said:
Hi All.

First Time Asking Here :)
Looking for the SQL for a query on a simple table
Table has 3 fields, all Integer with a number between 1 and 10000
All fields can have duplicates, however: The combination of numbers in
fields 1 and 2 will always be unique.

I am looking for a query that will return unique values of field 1
with the highest value of field 2.
So if my table contained this:
1 1 1
1 2 3
1 4 6
2 1 3
3 1 3
3 3 3
3 4 1
2 6 2
2 5 2
2 3 7
The Query would return:
1 4 6
2 6 2
3 4 1

Any ideas on the SQL for this, I'm stuck on this one.
Any help would be appreciated.
It's a simple grouping query:
Select Field1,Max(Field2) As MaxField2
FROM simpletable
GROUP BY Field1
 
I

Ivar

It's a simple grouping query:
Select Field1,Max(Field2) As MaxField2
FROM simpletable
GROUP BY Field

MAX, So simple I missed it :)
Thanks for that
All sorted

Thanks for quick reply

Ivar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top