nothingman,
No comment has been added lately (534 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
RECOMMENDATION: Award points to kelfink http:#7059820
Please leave any comments here within 7 days.
-- Please DO NOT accept this comment as an answer ! --
Thanks,
Squeebee
EE Cleanup Volunteer
Main Topics
Browse All Topics





by: kelfinkPosted on 2002-06-06 at 09:50:19ID: 7059820
Try using a LEFT JOIN, with a forced null comparison:
---------- -----+ ---------- -----+ ---------- -----+
create table ratings ( groupid int, rating int, data varchar(30) );
insert into ratings values ( 1, 10, 'some row');
insert into ratings values ( 1, 20, 'some other row');
insert into ratings values ( 1, 30, 'the right row for 1');
insert into ratings values ( 2, 10, 'some row');
insert into ratings values ( 2, 20, 'the right row for 2');
insert into ratings values ( 3, 30, 'the right row for 3');
select r.*
from ratings r left join ratings higher
on r.groupid = higher.groupid and r.rating < higher.rating
where higher.groupid is null;
+---------+--------+------
| groupid | rating | data |
+---------+--------+------
| 1 | 30 | the right row for 1 |
| 2 | 20 | the right row for 2 |
| 3 | 30 | the right row for 3 |
+---------+--------+------
3 rows in set (0.00 sec)