您的位置:首页 > 数据库

SqlServer-删除某一个字段重复的记录,只保留一条

2012-05-09 11:18 239 查看
删除pop_code重复的记录

DELETE FROM delivery_plan_product WHERE pop_code in

(SELECT pop_code FROM delivery_plan_product GROUP BY pop_code HAVING COUNT(pop_code) > 1)

and delivery_plan_product_id not in

(SELECT min(delivery_plan_product_id) FROM delivery_plan_product GROUP BY pop_code HAVING COUNT(pop_code)>1)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: