| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL help. Counting duplicate rows (Grrrr kill users!)
Try this:
select
col1,
count(*) / count(distinct col2)
from table
group by col1
;
Assuming, as you said, that for each value of col1, each value of col2 has been duplicated the same number of times, this should give you that number of times.
For eliminating duplicates, I've found the following useful:
begin
for rec in (
select
col1,
col2,
min(rowid) as line
from table
group by
col1,
col2
) loop
delete from table
where col1 = rec.col1
and col2 = rec.col2
and rowid <> rec.line
;
-- Zev Sero Don't blame me, I voted for Harry Browne zsero_at_mail.idt.net zsero_at_technimetrics.comReceived on Thu Nov 28 1996 - 00:00:00 CST
![]() |
![]() |