View
slot_availability
Booked, admitted and remaining places for every dated slot. Replaces the stored 2020 count.
Rows 126–150 of 443
| slot_idINTEGER | exhibition_idINTEGER | titleTEXT | slot_dateTEXT | start_timeTEXT | capacityINTEGER | bookedany | admittedany | remainingany |
|---|---|---|---|---|---|---|---|---|
| 126 | 6 | Light on the Water: Venetian Views | 2017-05-13 | 11:00 | 35 | 4 | 3 | 31 |
| 127 | 6 | Light on the Water: Venetian Views | 2017-05-14 | 14:30 | 35 | 2 | 1 | 33 |
| 128 | 6 | Light on the Water: Venetian Views | 2017-05-18 | 12:15 | 35 | 1 | 1 | 34 |
| 129 | 6 | Light on the Water: Venetian Views | 2017-05-18 | 13:15 | 35 | 2 | 1 | 33 |
| 130 | 6 | Light on the Water: Venetian Views | 2017-05-20 | 14:15 | 35 | 3 | 3 | 32 |
| 131 | 6 | Light on the Water: Venetian Views | 2017-05-20 | 17:15 | 35 | 1 | 1 | 34 |
| 132 | 7 | Cities of Clay: Mesopotamia | 2017-10-10 | 11:00 | 45 | 42 | 41 | 3 |
| 133 | 7 | Cities of Clay: Mesopotamia | 2017-10-10 | 17:15 | 45 | 4 | 4 | 41 |
| 134 | 7 | Cities of Clay: Mesopotamia | 2017-10-21 | 10:15 | 45 | 1 | 1 | 44 |
| 135 | 7 | Cities of Clay: Mesopotamia | 2017-10-22 | 12:15 | 45 | 1 | 1 | 44 |
| 136 | 7 | Cities of Clay: Mesopotamia | 2017-10-28 | 11:45 | 45 | 4 | 3 | 41 |
| 137 | 7 | Cities of Clay: Mesopotamia | 2017-10-28 | 15:15 | 45 | 1 | 1 | 44 |
| 138 | 7 | Cities of Clay: Mesopotamia | 2017-11-06 | 14:30 | 45 | 43 | 41 | 2 |
| 139 | 7 | Cities of Clay: Mesopotamia | 2017-11-11 | 13:00 | 45 | 2 | 0 | 43 |
| 140 | 7 | Cities of Clay: Mesopotamia | 2017-11-18 | 12:00 | 45 | 2 | 2 | 43 |
| 141 | 7 | Cities of Clay: Mesopotamia | 2017-11-22 | 13:00 | 45 | 45 | 37 | 0 |
| 142 | 7 | Cities of Clay: Mesopotamia | 2017-11-22 | 13:15 | 45 | 13 | 10 | 32 |
| 143 | 7 | Cities of Clay: Mesopotamia | 2017-11-23 | 15:00 | 45 | 1 | 1 | 44 |
| 144 | 7 | Cities of Clay: Mesopotamia | 2017-12-06 | 11:45 | 45 | 2 | 2 | 43 |
| 145 | 7 | Cities of Clay: Mesopotamia | 2017-12-06 | 12:45 | 45 | 1 | 0 | 44 |
| 146 | 7 | Cities of Clay: Mesopotamia | 2017-12-07 | 10:45 | 45 | 2 | 1 | 43 |
| 147 | 7 | Cities of Clay: Mesopotamia | 2017-12-10 | 17:00 | 45 | 2 | 0 | 43 |
| 148 | 7 | Cities of Clay: Mesopotamia | 2017-12-17 | 12:00 | 45 | 2 | 2 | 43 |
| 149 | 7 | Cities of Clay: Mesopotamia | 2017-12-17 | 12:45 | 45 | 2 | 2 | 43 |
| 150 | 7 | Cities of Clay: Mesopotamia | 2017-12-19 | 12:15 | 45 | 1 | 1 | 44 |
View definition
CREATE VIEW slot_availability AS
SELECT
s.slot_id,
s.exhibition_id,
e.title,
s.slot_date,
s.start_time,
s.capacity,
count(b.booking_id) AS booked,
count(h.scan_id) AS admitted,
s.capacity - count(b.booking_id) AS remaining
FROM exhibition_slot s
JOIN exhibition e ON e.exhibition_id = s.exhibition_id
LEFT JOIN exhibition_booking b ON b.slot_id = s.slot_id
LEFT JOIN hall_napoleon_scan h ON h.booking_id = b.booking_id
GROUP BY s.slot_id;