AdvancedWHERE & Filtering
Find duplicate emails in customers table
The query
SQL
SELECT email, COUNT(*) AS occurrences
FROM customers
WHERE email IS NOT NULL
GROUP BY email
HAVING COUNT(*) > 1
ORDER BY occurrences DESC;Note
“Classic duplicate-detection pattern using GROUP BY + HAVING COUNT > 1.