lto:[EMAIL PROTECTED]
Sent: Wednesday, April 21, 2004 1:46 PM
To: Chris
Cc: [EMAIL PROTECTED]
Subject: Re: Confused by max and group by
This seems bizarre. Although I am the SQL neophyte and it is perhaps not
my right to whine about the mysteries of SQL, but this seem very surprising
and nonint
The problem you are running into is that you are getting the max of one
field and grouping by another. But then you want to get a third field
that changes within the grouping.
Perhaps this might work
SELECT myindex, myval, mycat
FROM `mytest`
GROUP BY mycat
ORDER BY myindex DESC;
I think what is happening is that you are getting the max value for one
field, but the "first" values for the other fields. Try ordering you
group by:
SELECT max(myindex), myval, mycat
FROM `mytest`
GROUP BY mycat DESC;
On Apr 21, 2004, at 1:35 PM, Noah Spurrier wrote:
I'm having trouble with "
ROTECTED]
Sent: Wednesday, April 21, 2004 10:35 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Confused by max and group by
I'm having trouble with "max()" and "group by".
It seems pretty simple. I hope someone can point out my mistake.
I want to
I'm having trouble with "max()" and "group by".
It seems pretty simple. I hope someone can point out my mistake.
I want to select the max index of a group.
In other words, I want to find the last record added for each group.
The problem I'm having is that the columns of the resulting rows
are mix