If there is need to select or remove data from table which are duplicate by multiple fields (field1 and field2) in the below example, there can be used query like
WITH cte
AS (SELECT ROW_NUMBER() OVER (PARTITION BY field1, field2
ORDER BY ( SELECT 0)) RN
FROM mst_table)
DELETE FROM cte
WHERE RN > 1;
WITH cte
AS (SELECT ROW_NUMBER() OVER (PARTITION BY field1, field2
ORDER BY ( SELECT 0)) RN
FROM mst_table)
DELETE FROM cte
WHERE RN > 1;
No comments:
Post a Comment