Problem Statement

Write SQL queries to find and handle duplicate data: customers(id, name, email, phone, city) 1. Find all duplicate emails (emails that appear more than once) 2. Show all rows that have duplicate emails (all duplicates, not just count) 3. Keep only the first occurrence of each email and delete the rest (write the DELETE query using CTE or subquery with ROW_NUMBER)

Sample Data

customers:
(1,'Alice','alice@x.com','9876543210','Mumbai'),
(2,'Alicia','alice@x.com','9876543211','Delhi'),
(3,'Bob','bob@x.com','9123456789','Pune'),
(4,'Bobby','bob@x.com','9123456780','Chennai'),
(5,'Carol','carol@x.com','9000000001','Bangalore')

Expected Output

Q1: alice@x.com (2), bob@x.com (2)
Q2: rows 1,2 for Alice and rows 3,4 for Bob
Q3: DELETE keeps id=1 and id=3, deletes id=2 and id=4

Your Submission

ℹ️ The AI reads and reviews your code — it does not run it. Runtime errors like missing files or wrong paths won't affect your score. Focus on writing clean, correct logic.
Submit your work — choose one or more options
OR
OR