SQL: delete duplicate rows.
Asked in the R1 stage as one of 2-3 easy SQL questions. Write a PostgreSQL query that removes duplicate rows from sales_records, keeping the row with the smallest id for each identical set of non-id values.
deleted_id| Column | Type | Description |
|---|---|---|
| idPK | INT | Unique sales record identifier |
| store_id | INT | Store identifier |
| product_sku | VARCHAR(30) | Product stock keeping unit |
| sale_date | DATE | Date of sale |
| quantity | INT | Units sold |
| unit_price | DECIMAL(10,2) | Price per unit |