Q:

Delete duplicate records from a table only if the count is greater than 3

I have a table as follows:
A|B|C
1|2|3
1|2|3
1|2|3
1|2|3
1|2|3
4|5|6
4|5|6
4|5|6
4|5|6
7|8|9
7|8|9
7|8|9
I want to remove the duplicates and retain only one value for the record which appear more than 3 times.  It should be like:
A|B|C
1|2|3
4|5|6
7|8|9
7|8|9
7|8|9
I have the following code:
DELETE FROM test5 X
WHERE x.ROWID > ANY
  (SELECT Y.ROWID
    FROM test5 Y
    WHERE
      X.A = Y.A
     AND
      X.B = Y.B
    AND
      X.C = Y.C
    ); 

How can I keep only one duplicate of first two tuples(123 and 456) and retain all duplicates of third tuple? 

A:

If I understand your question clearly, why not restrict the deletion to those rows with the desired values using subquery.  Something like this:
DELETE FROM test5 x
WHERE x.ROWID >
ANY( select y.ROWID
FROM test5 y
WHERE X.AA = Y.AA
    AND
      X.BB = Y.BB
    AND
      X.CC = Y.CC)
AND (X.AA, X.BB, X.CC) IN (
SELECT AA, BB, CC FROM TEST5
GROUP BY AA, BB, CC
HAVING COUNT(AA) > 3);

This should delete duplicates of the first two tuples only.