Created
January 25, 2012 03:40
-
-
Save jpadilla/1674570 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT outlet_name, | |
IFNULL(SUM(reservation_pax), 0) AS reserved, | |
outlet_max_capacity, | |
( outlet_max_capacity - IFNULL(SUM(reservation_pax), 0) ) AS available | |
FROM `outlets` | |
LEFT JOIN `reservations` | |
ON `reservations`.reservation_outlet_id = `outlets`.outlet_id | |
AND reservation_date = '2011-09-22' | |
AND HOUR(reservation_time) = '17' | |
GROUP BY outlet_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT outlet_name, | |
IFNULL(SUM(reservation_pax), 0) AS reserved, | |
outlet_max_capacity, | |
( outlet_max_capacity - IFNULL(SUM(reservation_pax), 0) ) AS available | |
FROM `outlets` | |
LEFT JOIN `reservations` | |
ON `reservations`.reservation_outlet_id = `outlets`.outlet_id | |
AND reservation_date = CURDATE() | |
AND HOUR(reservation_time) = HOUR(CURTIME()) | |
GROUP BY outlet_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment