UPDATE tsgz_network_info_app
SET delete_flag = 1
WHERE id IN (
SELECT id
FROM (
SELECT id,tsgz_dept_app_id,adsl,ROW_NUMBER() OVER (PARTITION BY tsgz_dept_app_id, adsl ORDER BY id) AS row_num
FROM tsgz_network_info_app
WHERE network_access_type = 2 and delete_flag=0
) tmp
WHERE tmp.row_num > 1
);
根据tsgz_dept_app_id ,adsl 筛出重复的 ROW_NUMBER() OVER (PARTITION BY tsgz_dept_app_id, adsl ORDER BY id) AS row_num 使用这个函数进行筛选