Database schema: create table Repair(Id integer Primary Key, Deleted integer, Description varchar(25), Name varchar(100), LaborBillingRate decimal(18,2), Type Integer FK->RepairTypes.Id, ItemTypeId FK->ItemTypes.Id);Create Table CompletedRepair(id integer Primary Key, CreatedOn DateTime, TransactionId Integer FK->Transactions.id, UserId Integer FK->ApplicationUsers.Id, Itemid integer FK->Items.id, LocationId Integer FK->Locations.Id, RepairId Integer FK->Repair.Id, Quantity Integer, LaborCost Decimal(10,3), ActualCost Decimal(10,3));Create Table CompletedRepairPart(CompletedRepairId Integer FK->CompletedRepair.Id, RepairPartId Integer FK->RepairParts.Id, RepairPartcost decimal(10,3), Quantity Integer);Create Table RepairParts(Id integer Primary Key, Deleted Integer, PartNumber varchar(100), Description varchar(200), ReorderPoint integer, BillingPrice Decimal(8,2));
Question: how much did completed repairs cost
SQL: select sum(ActualCost) from CompletedRepair CR join CompletedRepairPart CRP on cr.id = CRP.CompletedRepairId join Repair RP on CR.RepairId = RP.id join RepairParts RPP on CRP.RepairPartId = RPP.Id