I have the attached SQL,that works fine for figuring out the amount of days booked in each month.
However as soon as the startDate and endDate are in different months it would give a false result, because its only grouped on the startDate.
How do i solve this issue ?
I want to know how many days were booked in each month.
SELECT month(hotel_sDate),year(hotel_sDate),sum(DATEDIFF(d, hotel_sDate, hotel_eDate) )
group by month(hotel_sDate),year(hotel_sDate)