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

Reply via email to