MySQL Forums
Forum List  »  Newbie

Re: SELECT grouping problem with MAX()
Posted by: Lyle Hopkins
Date: January 20, 2008 02:31PM

Hi,
Thanks for the help.

After more than 3 hours of searching, and now minus a lot of hair, I finally found the solution.

SELECT pl.username, amount, pl1.date FROM paylist pl1 JOIN ( SELECT username, MAX( date ) AS date FROM paylist pl2 GROUP BY username ) AS pl2 ON pl1.username = pl2.username AND pl1.date = pl2.date

I've found it to be a lot quicker than the left join

If you ask me it should match up the rows by default. Either way, hopefully this'll save someone else from a lot of stress.

Options: ReplyQuote


Subject
Written By
Posted
Re: SELECT grouping problem with MAX()
January 20, 2008 02:31PM


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.