Detect repeated values that should be unique.
Section: Data Quality and Maintenance Queries
Find duplicate business keys
sql
sql
SELECT email, COUNT(*) AS duplicate_count
FROM users
GROUP BY email
HAVING COUNT(*) > 1;Explanation
This query is often the first step before cleanup and adding a unique constraint.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Data Quality and Maintenance Queries
Delete duplicate rows with a CTE
Keep one row per key and delete the extras.
Explain with runtime stats
Run a query and collect timing or actual row information where supported.