Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Please help write a query **Urgent** tks

Re: Please help write a query **Urgent** tks

From: Richard Senior <richard_at_milldam.com>
Date: 31 Jul 2001 08:48:20 GMT
Message-ID: <9k5rck$mps$2@gate.local>

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, England
Received on Tue Jul 31 2001 - 03:48:20 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US