Wednesday, 9 December 2015

Find duplicate records in SQL

Here are some example to find duplicate records.
It will be very helpful if you want to add new unique validation, at that time you need to remove/rename duplicate records.


SELECT name, COUNT(email)
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

select name, count(sample_id)
from `tabJob Card Creation`
GROUP BY sample_id
HAVING (count(sample_id)>1);

select name, count(customer_name)
from `tabCustomer`
GROUP BY customer_name
HAVING (count(customer_name)>1);

No comments:

Post a Comment