First thing is that the definition you give in the "content" section does not match the condition you give in the query
OperationTypeID = 4 (Sales)
SUM(A.Output) AS Sales = (SELECT * from Log WHERE Log.OperationType_ID = 2)
Second thing was that your query seems quite wordy. You could replace that with something a lot simpler
SELECT Sales = Sum(Output), SalesReturn = Sum(Input)
FROM @log
WHERE OperationTypeID IN (4, 5)
As for the log table design, I would have additional columns for items such as LogDateTime & TransactionID. I also have an aversion to column names that are either keywords or reserved words; notice that
Output
is blue in the query, so I would probably rename to something like InventoryRemoved and then change the input column to be similarly named like InventoryAdded