Re: LIMIT within GROUP BY

2007-10-05 Thread Miroslav Monkevic
I tried. Then I get: ### person_idpoints 1 34 2 49 2 46 2 37 3 42 3 35 3 24 instead of desired: person_idpoints 1

Re: LIMIT within GROUP BY

2007-10-05 Thread Baron Schwartz
Change the > to >= and the < to <= to deal with this. Baron Miroslav Monkevic wrote: Thanks Baron, great advice (as always). My real query is a bit more complicated but speaking in terms of example I provided, I took this path: create table results ( person_id int(11),

Re: LIMIT within GROUP BY

2007-10-05 Thread Miroslav Monkevic
Thanks Baron, great advice (as always). My real query is a bit more complicated but speaking in terms of example I provided, I took this path: create table results ( person_id int(11), points int(11) ); insert into results values(1, 34); insert into results values(1, 33

Re: LIMIT within GROUP BY

2007-10-04 Thread Peter Brawley
Miroslav >My goal is to sum 7 greatest results for each person. Have a look at 'Within-group quotas (Top N per group)' at http://www.artfulsoftware.com/infotree/queries.php. PB - Miroslav Monkevic wrote: Hello, MySQL 4.1 I have query: SELECT SUM(points) as ranking FROM results GROUP

Re: LIMIT within GROUP BY

2007-10-04 Thread Baron Schwartz
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 i

LIMIT within GROUP BY

2007-10-04 Thread Miroslav Monkevic
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. Thank yo