| 10,28 → 10,29 |
| `housing_room`.`room`, `housing_room`.`roomtype`, |
| `housing_room`.`capacity`, `housing_room`.`gender`, |
| `housing_room`.`is_ra`, |
| COALESCE(`hc`.`hold_count`, 0) + `bc`.`booking_count` AS `count` |
| FROM ( |
| COALESCE(`hc`.`hold_count`, 0) + COALESCE(`bc`.`booking_count`, 0) AS `count` |
| FROM `housing_room` |
| LEFT JOIN ( |
| SELECT |
| `housing_booking`.`room_id`, COUNT(*) AS `booking_count` |
| FROM `housing_booking` |
| WHERE |
| `housing_booking`.`start` >= \'2010-09-19\' AND |
| `housing_booking`.`end` <= \'2011-06-11\' |
| `housing_booking`.`start` <= \'2010-09-19\' AND |
| `housing_booking`.`end` >= \'2010-09-19\' |
| GROUP BY `housing_booking`.`room_id` |
| ) AS `bc` |
| INNER JOIN |
| `housing_room` ON `bc`.`room_id` = `housing_room`.`id` |
| ON `housing_room`.`id` = `bc`.`room_id` |
| LEFT JOIN ( |
| SELECT |
| `housing_hold`.`room_id`, |
| SUM(`housing_hold`.`space`) AS `hold_count` |
| FROM `housing_hold` |
| WHERE `housing_hold`.`start` <= \'2010-09-19\' AND |
| `housing_hold`.`end` >= \'2011-06-11\' |
| WHERE |
| `housing_hold`.`start` <= \'2010-09-19\' AND |
| `housing_hold`.`end` >= \'2010-09-19\' |
| GROUP BY `housing_hold`.`room_id` |
| ) AS `hc` |
| ON `bc`.`room_id` = `hc`.`room_id` |
| ON `housing_room`.`id` = `hc`.`room_id` |
| WHERE `housing_room`.`end` > \'2090-01-01\' |
| HAVING `housing_room`.`capacity` > `count`'; |
| |