> 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. RBS On Thu, Mar 24, 2011 at 7:37 PM, Igor Tandetnik <itandet...@mvps.org> wrote: > On 3/24/2011 3:32 PM, Bart Smissaert wrote: >> Couldn't get this to work yet. >> What would be the full SQL, including the order by clause? > > 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); > > Deletes all but the most recent entry for each patient. Is this what you > are after? > -- > 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