MySQL Forums
Forum List  »  General

Re: Select Average of one group to compare with another
Posted by: Rick James
Date: October 10, 2015 07:40PM

SELECT  AVG(CASE WHEN id < 3 THEN trans ELSE NULL END) AS AvgTrans,
        AVG(CASE WHEN id = 3 THEN trans ELSE NULL END) AS id3Trans,
        month
    FROM tbl
    GROUP BY month;

Options: ReplyQuote


Subject
Written By
Posted
Re: Select Average of one group to compare with another
October 10, 2015 07:40PM


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.