ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل EMANDI NAGA SRIKANTH
تاريخ النشر: 2016/09/16
Sarah Dwekat
من قبل 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
من قبل 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
من قبل 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
من قبل Dawood Ahmed , Expert Software Engineer , Jazz

for this you have to use Group by and distinct

Ramya Shri G S
من قبل 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.

المزيد من الأسئلة المماثلة