Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Days to First Repair per Product

For each sale that had a repair, compute days from sale to its first repair, then return each product name and the average of those values rounded to 1 decimal. Order by name.

Table schema

Products(product_id INT PRIMARY KEY, name VARCHAR(20), warranty_months INT)
Sales(sale_id INT PRIMARY KEY, product_id INT, sale_date DATE)
Repairs(repair_id INT PRIMARY KEY, sale_id INT, repair_date DATE, cost INT)

Sample data

Products
product_id | name | warranty_months
1 | Laptop | 12
2 | Phone | 6
3 | Tablet | 12

Sales
sale_id | product_id | sale_date
1 | 1 | 2026-01-10
2 | 2 | 2026-01-15
3 | 1 | 2026-02-01
4 | 3 | 2026-02-10

Repairs
repair_id | sale_id | repair_date | cost
1 | 1 | 2026-05-01 | 100
2 | 2 | 2026-08-20 | 80
3 | 1 | 2026-09-01 | 60
4 | 3 | 2027-03-01 | 150
5 | 2 | 2026-06-01 | 40

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.