Hey there! any question in your mind? Ask It Now!.

Popular Categories





print duplicate entry from a table with their count

+12 votes
136 views
asked in Programming by Himanshu Expert (5,940 points)
How to print duplicate entry from a table with their count? my table has junk data and want to see the duplicates values, can you tell me the exact query for the same?

1 Answer

+4 votes
answered by Eathen (1,930 points)
selected by Himanshu
 
Best answer

For print duplicate entry from a table with their count see this query ->

select * FROM

(SELECT ROW_NUMBER() OVER (PARTITION BY fname  ORDER BY fname) cnt,*

FROM USER_TABLE)  duplicates
 
WHERE duplicates.Cnt > 1
NOTE: Here  fname is column name and USER_TABLE is table in which you want to find duplicate entries.
commented by Himanshu Expert (5,940 points)
yah thanks dear.
commented by nitu (1,680 points)
Nice work @Eathen it helped me also.
commented by Pankaj
Or you might use this query :

mysql>  select COLUMN_NAME_HERE, count(*) as c from TABLE_NAME_HERE group by COLUMN_NAME_HERE;

Related Questions

+8 votes
1 answer 130 views
+8 votes
2 answers 139 views
+6 votes
1 answer 158 views
+2 votes
1 answer 131 views
+1 vote
0 answers 120 views
+2 votes
1 answer 905 views
+1 vote
1 answer 1,127 views
+7 votes
7 answers 1,555 views
0 votes
0 answers 480 views

Not a Member yet?

Ask to Folks Login

My Account
694 Folks are online
6 members and 688 guest online
Your feedback is highly appreciated