Re: Find double (not uniqe) entries in a table
Posted by:
Aziz
Date: August 17, 2005 06:21AM
My previously proposed query only selects one non-distinct row because of the GROUP BY. If you want to select all non-unique rows, then the query should look like this:
SELECT id, name, city FROM a_table
WHERE name IN
(SELECT name
FROM a_table
GROUP BY name
HAVING COUNT(name) > 1)
Or perhaps so:
SELECT id, name, city FROM a_table a1
WHERE EXISTS(
SELECT name
FROM a_table a2
WHERE a2.name = a1.name
GROUP BY a2.name
HAVING COUNT(a2.name) > 1)
Hope this helps.
Regards,
Aziz
Subject
Written By
Posted
Re: Find double (not uniqe) entries in a table
August 17, 2005 06:21AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.