Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

get a count of duplicates

How can I count the number of duplicates in a table.  Thanks
0
running32
Asked:
running32
  • 2
  • 2
1 Solution
 
slightwv (䄆 Netminder) Commented:
On all columns or just certain columns?


0
 
running32Author Commented:
a count and all columns.

thanks
0
 
slightwv (䄆 Netminder) Commented:
Try the code below.  just add the columns to the where clause.
drop table tab1 purge;
create table tab1(col1 char(1), col2 char(1));

insert into tab1 values('a','b');
insert into tab1 values('a','b');
insert into tab1 values('a','b');
insert into tab1 values('c','d');
commit;

select count(*)
from tab1 t1
where rowid>(select min(rowid) from tab1 t2 where
	t1.col1=t2.col1 and
	t1.col2=t2.col2
)
/

Open in new window

0
 
running32Author Commented:
thanks
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now