Jeg tror, at du ikke kan gøre det hele på én gang, som du prøver, fordi du vil gruppere/summe elementer fra forskellige tabeller på samme tid. Prøv dette:
select unit, name, stays, days, total_price, charges, mgmt_fee,
(total_price*.01*mgmt_fee) AS management,
(total_price-(total_price*.01*mgmt_fee)-charges) AS bal
from (
select
x.unit,
name,
count(*) as stays,
sum(days) as days,
sum(total_price) as total_price,
charges,
mgmt_fee
from
(select
unit ,
datediff(depart,arrival) as days,
total_price
from
Reservations
) as x
join (
select unit, sum(amount) as charges
from Charges
group by unit
) as y
on x.unit = y.unit
join Unit as u
on u.id = x.unit
group by unit
) as inner_result
Ikke særlig ryddeligt eller elegant, men jeg synes, det virker. Bemærk, at du skal være forsigtig, hvis der kan være> 1 række i afgifter pr. enhed. Her er en violin, der viser, at den kører:http://sqlfiddle.com/#!2/f05ba/18