Have I to break this query
SELECT
ISNULL(SUM(AF.[amount]), 0) AS [firm],
ISNULL(SUM(ACA.[amount]), 0) AS [cash],
ISNULL(SUM(AC.[amount]), 0) AS [client],
ISNULL(SUM(AFR.[amount]), 0) AS [fr],
ISNULL((SUM(AF.[amount]) + SUM(ACA.[amount]) - (SUM(AC.[amount]) + SUM(AFR.[amount])), 0) AS [total]
FROM ...
into two:
DECLARE @firm DECIMAL(14,2), @client DECIMAL(14,2), @fr DECIMAL(14,2), @cash DECIMAL(14,2)
SELECT @firm = SUM(AF.[amount]), @client = SUM(AC.[amount]), @fr = SUM(AFR.[amount]), @cash = SUM(ACA.[amount])
FROM ...
SELECT
ISNULL(@firm, 0) AS [firm],
ISNULL(@cash, 0) AS [cash],
ISNULL(@client, 0) AS [client],
ISNULL(@fr, 0) AS [fr],
ISNULL((@firm + @cash) - (@client + @fr), 0) AS [total]
?