How do you find duplicate values in a column?
Model answer
SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1. To remove duplicates safely, first select the rows you will delete, keep one per group (for example the lowest id), and run it inside a transaction.
Learn this topic
GROUP BY and HAVING: Summaries for Each Group in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.