"Gary O'Brien" <mrmc...@frii.com> wrote in message
news:93fda2e5d3cb442884be95e1b84fc...@garysldc13y00e
> Given the following table and data, I'd like to remove
> all items with duplicate types within a container,
> keeping the most recent (largest item_id) item of that
> type within each container.

delete from item where exists (
    select 1 from item item2
    where item2.container_id = item.container_id
        and item2.type = item.type
        and item2.item_id > item.item_id);

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to