hi
what is the query to fetch duplicate records in oracle table.

Recommended Answers

I think it's the same with SQL:

select field1 ,count(*) from table
group by field1
having count(*) > 1 

or

select * from table
where field1 in 
(select field1 from table
 group by field1
 having count(*) > 1 )
Jump to Post

What exactly you mean by duplicate records.

Duplicate based on what ?

Jump to Post

All 5 Replies

I think it's the same with SQL:

select field1 ,count(*) from table
group by field1
having count(*) > 1 

or

select * from table
where field1 in 
(select field1 from table
 group by field1
 having count(*) > 1 )

What exactly you mean by duplicate records.

Duplicate based on what ?

select <column_name>,count(*) from <table_name> group by <column_name> having count<column_name> >1

If you wanna fetch and check through the duplicates, you'd gotta use a cursor.

@SQLpower: Why?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.