Re: Finding Max of a DB field and then return whole record grouping on one column
- From: smartin <smartin108@xxxxxxxxx>
- Date: Sat, 09 Aug 2008 20:13:35 -0400
Paul W Smith wrote:
I have a table as below:
X 210 5 TRUE A
Y 220 7 FALSE B
X 210 3 TRUE D
Y 219 1 TRUE B
Z 215 4 TRUE C
Z 212 5 FALSE D
X 209 1 TRUE A
Y 220 2 TRUE A
Z 221 3 TRUE B
What I am looking to return is the following, whether this by one complicated query or a series of Queries:
X 210 3 TRUE D
Y 220 2 TRUE A
Z 221 3 TRUE B
I am trying to group on the first column and then find the Max of the second column, and where this is equal, to use the record which has the Max of the third column.
I do not wish to use any custom VBA functions.
I'm not following your logic here:
Within X, max(col 2) is 210, within that, max(col 3) is 5 (not 3)
Within Y, max(col 2) is 220, within that, max(col 3) is 7 (not 2)
Within Z, max(col 2) is 221, within that, max(col 3) is 3 (ok fine)
Did you mean
> I am trying to group on the first column and then find the Max of the second
> column, and where this is equal, to use the record which has the /last/ of the
> third column.
Is so, can you ensure the order of the records is consistent? (Note: Selecting a table without ordering will not necessarily produce consistent results.)
.
- Follow-Ups:
- References:
- Prev by Date: Finding Max of a DB field and then return whole record grouping on one column
- Next by Date: Help with Decimal.
- Previous by thread: Finding Max of a DB field and then return whole record grouping on one column
- Next by thread: Re: Finding Max of a DB field and then return whole record grouping on one column
- Index(es):
Relevant Pages
|