Forums
This topic is locked
Recordset with max value
08 Jun 2008 21:07:18 john culp posted:
I want to create a recordset using group by whose records reflect the max value of a field. For example... the table is this-
Fld 1 Fld 2
A 1
A 2
A 3
B 1
B 2
B 3
I want the recordset to reflect the highest values of Fld 2, grouped by Fld 1. So the recordset needs to be-
A 3
B 3
I tried ordering by and grouping by hoping it would take the highest value, but it didn't. Using the query-
Select max(fld1) as max, fld1, fld2
group by fld1
max is correct, but the records themselves were not the records based on the max. The recordset would look like this-
max fld1 fld2
3 A 2
3 B 1
It groups them by fld1, but doesn't filter the record that the max fld1 would yield.
I want the result to be-
max fld1 fld2
3 A 3
3 B 3
Am I making sense?