On 23 Apr 2010, at 11:03pm, Bart Smissaert wrote: > 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.
I can't think of a way to do it for all people in one command. Also your logic might be complicated to take care of the case where there was only one or two entries for a person. If you want to do it for just one person, try something like SELECT entry_id FROM xxx WHERE person_id=n ORDER BY entry_id DESC LIMIT 3 replacing 'n' with each person_id in turn. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users