MySQL Forums
Forum List  »  General

Re: create function help
Posted by: Rick James
Date: November 21, 2009 11:58AM

This might get the same value:

SELECT acc, yearmon AS ym, matd, disc
    FROM ( SELECT *
              FROM longacc_hist
              ORDER BY yearmon DESC
         )
    GROUP BY acc;
It uses the 'feature' that GROUP BY will take the first row from each group; the "ORDER BY yearmon DESC" arranges for the first row to have the MAX and the disc you are looking for.

Options: ReplyQuote


Subject
Written By
Posted
November 19, 2009 12:28PM
Re: create function help
November 21, 2009 11:58AM


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.