MySQL Forums
Forum List  »  Newbie

Specify order before group?
Posted by: Callum Macdonald
Date: June 27, 2005 10:57AM

Is it possible to specify order before grouping?

I want to group a list of user actions by user id with the most recent at the top. For example, the query would be:

SELECT * FROM UserActions ORDER BY Time DESC GROUP BY UserID;

That doesn't work because you have to specify GROUP BY before ORDER BY. However, the output of specifying them in the correct order is not what I want. It seems to pick the first record in the database as the GROUP instead of the most recent one.

What I'm actually trying to do is get a list of all the Users in order of the most recent UserAction, so as to be able to view the latest acitivity on my web site.

Any suggestions greatly appreciated,


chmac.

Options: ReplyQuote


Subject
Written By
Posted
Specify order before group?
June 27, 2005 10:57AM
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.