Repair Cost per Product
Easy
Warranty & Repairs
Return each product name and its total repair cost, with 0 when it has none. 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.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.