Top 2 sold products in each year provided data - SQL
Asked in the Round 2 technical stage, conducted in-office with the interviewer online. Write a SQL query using the provided product and sales data.
sales_year, product_id, product_name, total_units_sold, and sales_rank.product_id ascending.sales_year ascending, then sales_rank ascending.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product display name |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| product_id | INT | Product sold in the transaction |
| sold_at | DATE | Date of sale |
| quantity | INT | Number of units sold |