A broad look at what I'm trying to do is to find out how many more reservations have not yet been made, but in books throughout the system, by the reservation date. This means counting the number of all records that exist with redemption_date after or equal to booking_date , grouped by booking_date . For a better explanation, see the following hypothetical example:
redemption_date booking_date 2013-01-01 2013-01-01 2013-01-06 2013-01-01 2013-01-06 2013-01-01 2013-01-07 2013-01-02 2013-01-08 2013-01-03 2013-01-09 2013-01-04 2013-01-10 2013-01-05 2013-01-10 2013-01-05 2013-01-10 2013-01-05 2013-01-10 2013-01-05 2013-01-10 2013-01-05 2013-01-11 2013-01-05
I need the result:
booking_date number_of_reservations 2013-01-01 3 2013-01-02 3 2013-01-03 4 2013-01-04 5 2013-01-05 11
But my brain completely fails in how the query should be structured. Any tips? Thanks!
Edit: To clarify, number_of_reservations should be the number of reservations that were booked at this date, as well as those that were ordered on the days after that. In other words, number_of_reservations is the number of reservations that are in the database, starting with booking_date (which have not yet occurred). My initial results had errors. Sorry for the confusion
source share