Delete Duplicates Keeping the Latest Row
Medium
Data Cleaning
Subscriptions may contain several rows per email. Delete the older rows so that only the row with the latest updated_at per email remains.
Table schema
Subscriptions(id INT PRIMARY KEY, email VARCHAR(100), updated_at DATE)Sample data
id | email | updated_at
1 | a@x.com | 2026-01-01
2 | a@x.com | 2026-03-01
3 | b@x.com | 2026-02-01
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.