I thought of using the charge as charge per night. I tried to convert and subtract booking date and departure date. , multiplying the result with charge.
But it gives me 64 results of which majority are negative.
Select
((convert(numeric,B.idate) - convert(numeric,D.odate))*R.charge)
AS 'Total Earning'
From Room R, Booking B, Departure D
WHERE B.idate BETWEEN('2012-01-01') AND('2012-12-31')
AND D.odate BETWEEN('2012-01-01') AND('2012-12-31')
AND R.hno = 19
Group BY B.idate, D.odate, R.charge