SQL Query to summarize data based on dates
Hi,
I have a table which has following data
Booking number Booking amount Check-in Date Check-out Date
1 100 01-AUG-2015 03-AUG-2015
2 250 30-AUG-2015 04-SEP-2015
3 300 01-SEP-2015 02-SEP-2015
I want this data as follows
Month Booking Amount
AUG-15 200
SEP-15 450
Here for booking number 2, we are splitting booking amount evenly between all the dates. 2 days in august and 3 days (4th Sep is not counted as it is a check-out date) in September gets $50 each.
Can someone please help me in displaying the data is above format?
Thanks.