delete from subs b where browid<(select max(arowid) from subs a where amsid=bmsid and ams_type=bms_type and aareacode=bareacode);