Thanks, that works indeed fine. Will use that. RBS
On Thu, Mar 24, 2011 at 8:52 PM, Igor Tandetnik <itandet...@mvps.org> wrote: > On 3/24/2011 4:47 PM, Bart Smissaert wrote: >>> Deletes all but the most recent entry for each patient. Is this what you >> are after? >> >> Yes, that is exactly it. >> >> delete from xxx where entry_id not in ( >> select entry_id from xxx where xxx.patient_id = patient_id >> order by start_date desc limit 1); >> >> This deletes all but one record. It should be a few hundred out of a >> few thousand. > > Right. Make it > > delete from xxx where entry_id not in ( > select t2.entry_id from xxx t2 where xxx.patient_id = t2.patient_id > order by start_date desc limit 1); > > -- > 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