Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Select the table which duplicate rows are present in that table(only display duplicate rows without repetition )?

user-image
Question added by EMANDI NAGA SRIKANTH
Date Posted: 2016/09/16
Sarah Dwekat
by Sarah Dwekat , Database System Developer , Integrated Technology Group (ITG)

If i get your question right, you can use Distinct ( Select Distinct * from Table). it will show only unique rows data. 

 

Thomas Waszak
by Thomas Waszak , business under the name

SELECT field1, field2, COUNT(*)FROM table_name GROUPBY field1, field2 HAVING COUNT(*) =2

will show all only duplicated (inserted twice) rows. You must specify all fields with duplicated values.

To show all rows mutliplied (inserted twice and more times) :

SELECT field1, field2, COUNT(*)FROM table_name GROUPBY field1, field2 HAVING COUNT(*) >1

Gayasuddin Mohammed
by Gayasuddin Mohammed , Advocate , Practicing Law before High Court at Hyderabad

select f1,f2,f3 from tab group by fields..... having count(*) >1

you will get all duplicate rows by above...and then you can insert them into a tempdb...table or # table...then further you can query like select distinct f1,f2,f3 from tempdb..table or # table...is one possible solution.

 one other way may be...use the same above query and use intersect between the other query like select distinct f1,f2,f3 from table.,,should also work....not very sure as I am out of touch since long time, but logically it should work.

thanks for the invitation. 

Dawood Ahmed
by Dawood Ahmed , Expert Software Engineer , Jazz

for this you have to use Group by and distinct

Ramya Shri G S
by Ramya Shri G S , Software Developer , Tata Consultancy Services

We can use distinct function to eliminate the duplicate values

If I understood you correctly you should use distinct function to eliminate duplicate rows in the query, like this: select distinct * from ... but in this case distinct will check all columns and if some columns contains non duplicate data it won't eliminate duplicate rows, then try using window functions like row_number() or ranking functions like dense_rank.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.