If you just use SUM() function it will sum all the values of the table. If you want to sum only the related values, you have to first group the values by an id and then sum them. That's what the below sub query does.
Here is a model of Table1- Order_Line
Here is a model of Table2- Component_Used
I have filled only necessary details. You can see that there are multiple values of Order_LineQuantity for a given component.
And similarly multiple values exist for Component_UsedQuantity for a given component.
I have linked this using the ComponentID from Component Table.
SELECT ComponentID AS ComponentID,(ordertable.sumorder-componenttable.sumcomponent) as quantity
FROM Component,
(SELECT Order_LineComponentID as id,SUM(Order_LineQuantity) as sumorder FROM Order_Line GROUP BY Order_LineComponentID)ordertable,
(SELECT Component_UsedComponentID as id,SUM(Component_UsedQuantity) as sumcomponent FROM Component_Used GROUP BY Component_UsedComponentID)componenttable
WHERE
ComponentID=ordertable.id and ComponentID=componenttable.id
Now when you execute the query, it selects the required details after all the grouping operations.