MySQL Forums
Forum List  »  Newbie

Re: Specify order before group?
Posted by: Jay Pipes
Date: June 27, 2005 12:27PM

When using GROUP BY, you need to group on something. Doing SELECT * means you want all the columns in the table, then grouped by UserID? That doesn't make sense.

I think what you're looking for is something like:

SELECT UserID, MAX(Time) as 'LatestAction', COUNT(*) as 'NumActions'
FROM UserAction
GROUP BY UserID
ORDER BY 'LatestAction';

Is that more like it?

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
Re: Specify order before group?
June 27, 2005 12:27PM
ben
November 13, 2005 09:07PM


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.