DELETE FROM assembly_supply_chain a WHERE a.supply_chain_id> (
SELECT min(b.supply_chain_id ) FROM assembly_supply_chain b
WHERE a.mtl_item_code=b.mtl_item_code and a.subinventory_code=b.subinventory_code and a.production_line_code=b.production_line_code
and a.bh_type=b.bh_type and a.store_house_code=b.store_house_code and a.wip_supply_type=b.wip_supply_type
);
DELETE FROM MTL_LOGICAL_ZONE a WHERE a.id > (
SELECT min(b.id) FROM MTL_LOGICAL_ZONE b
WHERE b.mtl_item_id=a.mtl_item_id and a.logical_zone_id=b.logical_zone_id
);
/*****物料组***************/
DELETE FROM mtl_group_ref a WHERE a.id> (
SELECT min(b.id ) FROM mtl_group_ref b
WHERE a.mtl_item_id=b.mtl_item_id and a.mtl_category_id=b.mtl_category_id --and a.subinv_code=b.subinv_code
);
DELETE FROM MTL_LOGICAL_ZONE a WHERE a.id> (
SELECT min(b.id ) FROM MTL_LOGICAL_ZONE b
WHERE a.mtl_item_id=b.mtl_item_id and a.logical_zone_id=b.logical_zone_id
);
SELECT min(b.supply_chain_id ) FROM assembly_supply_chain b
WHERE a.mtl_item_code=b.mtl_item_code and a.subinventory_code=b.subinventory_code and a.production_line_code=b.production_line_code
and a.bh_type=b.bh_type and a.store_house_code=b.store_house_code and a.wip_supply_type=b.wip_supply_type
);
DELETE FROM MTL_LOGICAL_ZONE a WHERE a.id > (
SELECT min(b.id) FROM MTL_LOGICAL_ZONE b
WHERE b.mtl_item_id=a.mtl_item_id and a.logical_zone_id=b.logical_zone_id
);
/*****物料组***************/
DELETE FROM mtl_group_ref a WHERE a.id> (
SELECT min(b.id ) FROM mtl_group_ref b
WHERE a.mtl_item_id=b.mtl_item_id and a.mtl_category_id=b.mtl_category_id --and a.subinv_code=b.subinv_code
);
DELETE FROM MTL_LOGICAL_ZONE a WHERE a.id> (
SELECT min(b.id ) FROM MTL_LOGICAL_ZONE b
WHERE a.mtl_item_id=b.mtl_item_id and a.logical_zone_id=b.logical_zone_id
);