Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Please help write a query **Urgent** tks
In article <F_r97.106$nF6.2620_at_newscontent-01.sprint.ca>,
"OCP" <mr_ocp_at_yahoo.com> writes:
> We have a table the contains several duplicate records however each record
> is with an unique primary key, I need to write a query to see how many
> records are duplicate, there is a name field which has several duplicate
> names under separat unique id, so is there a way that I can find out how
> many such duplicate names exists in the table.
This will show all the IDs that appear in more than one record:
select the_not_quite_unique_id
from your_table
group by the_not_quite_unique_id
having count(*) > 1;
You could incorporate this as a correlated sub-query to get the rows themselves:
select the_not_quite_unique_id, the_name
from your_table
where the_not_quite_unique_id in (
select the_not_quite_unique_id from your_table group by the_not_quite_unique_id having count(*) > 1
-- Regards, Richard Senior Mill Dam Consulting Ltd London, EnglandReceived on Tue Jul 31 2001 - 03:48:20 CDT
![]() |
![]() |