Write a query to detect duplicate serial numbers in a product inventory table and keep only the most recent entry based on a timestamp.
Return one row per non-null serial number, retaining only its latest inventory record. If timestamps tie, retain the row with the greatest inventory_id.
inventory_id, serial_number, product_model, warehouse_code, inventory_status, and recorded_at.serial_number ascending.| Column | Type | Description |
|---|---|---|
| inventory_idPK | INT | Unique inventory record identifier |
| serial_number | VARCHAR(40) | Product serial number |
| product_model | VARCHAR(80) | Product model or component family |
| warehouse_code | VARCHAR(20) | Warehouse or facility code |
| inventory_status | VARCHAR(20) | Current status recorded for the inventory item |
| recorded_at | TIMESTAMP | Timestamp when the inventory record was recorded |