Interview practice question
Deleting duplicates and keeping one
Data Engineering · SQL · Beginner
A table has duplicate rows. How do you delete the duplicates but keep one copy of each?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Identify duplicates with ROW_NUMBER over the key.
- Keep row number 1 based on a clear rule like latest updated_at.
- In warehouses, often easier to rebuild the table with the deduplicated set.
- In OLTP, delete using a unique row identifier.
- Back up or clone before deleting.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.