You probably don't need the joins since the aggregate results come from the same table. You could instead use conditional aggregation
SELECT
SUM(CASE WHEN Completed = 1 THEN
[Fee Charge] + [Fee Charge VAT] + ExtraCharges + ExtraChargesVAT +
OtherCharges + OtherChargesVAT + WaitingCharge + [WaitingCharge VAT]
END) AS [Completed Turnover],
SUM(CASE WHEN InProgress = 1 THEN
...
END) AS [In-progress Turnover],
SUM(CASE WHEN Completed = 0 AND InProgress = 0 THEN
...
END) AS [Unallocated Turnover],
123 AS [Credit Note Value]
FROM tblreservation
and then unpivot the results using either of the methods in @bluefeet's answer:
SELECT
Caption,
Value
FROM (
SELECT
SUM(CASE WHEN Completed = 1 THEN
[Fee Charge] + [Fee Charge VAT] + ExtraCharges + ExtraChargesVAT +
OtherCharges + OtherChargesVAT + WaitingCharge + [WaitingCharge VAT]
END) AS [Completed Turnover],
SUM(CASE WHEN InProgress = 1 THEN
...
END) AS [In-progress Turnover],
SUM(CASE WHEN Completed = 0 AND InProgress = 0 THEN
...
END) AS [Unallocated Turnover],
123 AS [Credit Note Value]
FROM tblreservation
) AS s
UNPIVOT (
Value FOR Caption IN (
[Completed Turnover], [In-progress Turnover],
[Unallocated Turnover], [Credit Note Value]
)
) AS u
;
On the other hand, if InProgress
and Completed
are always either 1 or 0 and they have consistent values in that they cannot both be 1, you could group the results like this:
SELECT
Completed,
InProgress,
SUM(
[Fee Charge] + [Fee Charge VAT] + ExtraCharges + ExtraChargesVAT +
OtherCharges + OtherChargesVAT + WaitingCharge + [WaitingCharge VAT]
) AS Value
FROM tblreservation
GROUP BY
Completed,
InProgress
The next step would be to turn the combinations of Completed
and InProgress
into proper captions. One method is to use CASE:
SELECT
CASE
WHEN Completed = 1 THEN 'Completed Turnover'
WHEN InProgress = 1 THEN 'In-progress Turnover'
ELSE 'Unallocated Turnover'
END AS Caption
SUM(
[Fee Charge] + [Fee Charge VAT] + ExtraCharges + ExtraChargesVAT +
OtherCharges + OtherChargesVAT + WaitingCharge + [WaitingCharge VAT]
) AS Value
FROM tblreservation
GROUP BY
Completed,
InProgress
And then you would just add the constant Credit Note Value
with a UNION ALL:
SELECT
CASE
WHEN Completed = 1 THEN 'Completed Turnover'
WHEN InProgress = 1 THEN 'In-progress Turnover'
ELSE 'Unallocated Turnover'
END AS Caption
SUM(
[Fee Charge] + [Fee Charge VAT] + ExtraCharges + ExtraChargesVAT +
OtherCharges + OtherChargesVAT + WaitingCharge + [WaitingCharge VAT]
) AS Value
FROM tblreservation
GROUP BY
Completed,
InProgress
UNION ALL
SELECT
'Credit Note Value',
123
;