MySQL Forums
Forum List  »  Newbie

Re: MAX() and GROUP BY Problems...
Posted by: Chris Stubben
Date: April 27, 2005 09:36AM

Hi,

You can sort the results of a group by clause using the aggregate function, a column alias, or a column position (I think only the first is ANSI standard).


SELECT MAX(Date), MAX(Time), UserName FROM radius_accounting GROUP BY UserName ORDER BY MAX(Date) desc;

or

SELECT MAX(Date) as max_date, MAX(Time), UserName FROM radius_accounting GROUP BY UserName ORDER BY max_date desc;

or

SELECT MAX(Date), MAX(Time), UserName FROM radius_accounting GROUP BY UserName ORDER BY 1 desc;


Chris

Options: ReplyQuote


Subject
Written By
Posted
Re: MAX() and GROUP BY Problems...
April 27, 2005 09:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.