SQL Practice Logo

SQLPractice Online

Level 5 - SeniorQuery-Based Questions

Add Unique Constraint After Data Cleanup

Interviewer prompt: emails table has duplicates. You must enforce uniqueness on lower(email) after cleanup. Write SQL to delete duplicates keeping latest row, then add uniqueness protection.

Schema Context

user_emails(id, user_id, email, updated_at)