Měli byste sčítat CASE
výraz, který dokáže rozlišit mezi debety a kredity:
SELECT
Id,
TransactionType,
SUM(CASE WHEN TransactionType = 'Receipt' THEN value ELSE -1.0*value END)
OVER (ORDER BY Id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS DiffValue
FROM #Temp
ORDER BY Id;