List:General Discussion« Previous MessageNext Message »
From:Baron Schwartz Date:October 4 2007 10:15am
Subject:Re: LIMIT within GROUP BY
View as plain text  
Hi,

Miroslav Monkevic wrote:
> Hello,
> 
> MySQL 4.1
> 
> I have query:
> SELECT SUM(points) as ranking FROM results GROUP BY person_id ORDER BY 
> ranking DESC
> 
> My goal is to sum 7 greatest results for each person.
> 
> In more general, my question is: is there a way to limit number of 
> records within  groups in  "group by" query.

Try this:
http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

Cheers
Baron
Thread
LIMIT within GROUP BYMiroslav Monkevic4 Oct
  • Re: LIMIT within GROUP BYBaron Schwartz4 Oct
    • Re: LIMIT within GROUP BYMiroslav Monkevic5 Oct
      • Re: LIMIT within GROUP BYBaron Schwartz5 Oct
        • Re: LIMIT within GROUP BYMiroslav Monkevic5 Oct
  • Re: LIMIT within GROUP BYPeter Brawley4 Oct