DELETE FROM EXTERNAL_ENTITIES
WHERE
ROWID IN
(
SELECT "ROWID" -- ESCAPED, BECAUSE WE NEED THE INNER ROWID, NOT THIS TMPTABLE'S ROWID
FROM
(
SELECT
RANK() OVER(PARTITION BY NAME ORDER BY ROWID) RANK_N, -- ORDER IN THE SUBGROUP
ROWID AS "ROWID" , -- ESCAPE THE ROWID
FROM EXTERNAL_ENTITIES
WHERE
NAME IN
(
SELECT NAME
FROM EXTERNAL_ENTITIES
GROUP BY NAME
HAVING COUNT(*) > 1 -- ONLY DUPLICATES OR MORE
)
)
WHERE RANK_N > 1
);
or
DELETE FROM CUSTOMFIELDVALUE
WHERE ROWID IN
(SELECT T."ROWID" FROM
(SELECT RANK() OVER(PARTITION BY ISSUE, CUSTOMFIELD ORDER BY ROWID) RANK_N, ROWID AS "ROWID"
FROM CUSTOMFIELDVALUE
WHERE CUSTOMFIELD IN (10180, 10216, 10336, 10340, 10464, 10550, 10590, 10911, 14714) -- customfield ID-s come here, taken from the log.
) T
WHERE T.RANK_N > 1);
No comments :
Post a Comment