COUNT DUPLICATE RECORDS IN MYSQL -
i need query count duplicate records,
for example
table name -customer =================== customer_id-col name 222 111 222 222 111 122
output be
customer_id count 222 3 111 2 222 3 222 3 111 2 122 1
i tried query
select customer_id,count( customer_id ) c customer group customer_id having c >1
output is
customer_id count
222 3 111 2 122 1
is possible in advance
thanks raja
try this
select t.customer_id,s.duplicate_count ( select customer_id,count(customer_id) duplicate_count yourtable group customer_id having (duplicate_count > 0) ) s join yourtable on s.customer_id = t.customer_id
op:
customer_id count 222 3 111 2 222 3 222 3 111 2 122 1
Comments
Post a Comment