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

Popular Categories





print duplicate entry from a table with their count

+12 votes
123 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 117 views
+8 votes
2 answers 129 views
+6 votes
1 answer 145 views
+2 votes
1 answer 118 views
+1 vote
0 answers 112 views
+2 votes
1 answer 874 views
+1 vote
1 answer 1,055 views
+7 votes
7 answers 1,486 views
0 votes
0 answers 463 views

Not a Member yet?

Ask to Folks Login

My Account
741 Folks are online
0 members and 741 guest online
Your feedback is highly appreciated