> Will need to add maybe a compound index to make it faster. I bet it will be a lot slower than making several selects. But please test yourself. :)
Pavel On Fri, Apr 23, 2010 at 6:46 PM, Bart Smissaert <bart.smissa...@gmail.com> wrote: > Thanks; yes, that works. > Will need to add maybe a compound index to make it faster. > > RBS > > > On Fri, Apr 23, 2010 at 11:38 PM, Igor Tandetnik <itandet...@mvps.org> wrote: >> Bart Smissaert wrote: >>> Simplified there is a table like this: >>> >>> create table xxx( >>> [entry_id] integer primary_key, >>> [person_id] integer) >>> >>> Now I need to retrieve the rows with the 3 highest entry_id numbers >>> for each person_id. >> >> select * from xxx t1 >> where rowid in ( >> select rowid from xxx t2 >> where t1.person_id=t2.person_id >> order by t2.entry_id desc limit 3); >> >> -- >> Igor Tandetnik >> >> _______________________________________________ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users