View
slot_availability
Booked, admitted and remaining places for every dated slot. Replaces the stored 2020 count.
Rows 276–300 of 443
| slot_idINTEGER | exhibition_idINTEGER | titleTEXT | slot_dateTEXT | start_timeTEXT | capacityINTEGER | bookedany | admittedany | remainingany |
|---|---|---|---|---|---|---|---|---|
| 276 | 10 | Bodies in Marble | 2019-05-27 | 12:00 | 45 | 2 | 2 | 43 |
| 277 | 11 | Porcelain for Kings | 2019-06-12 | 11:00 | 40 | 1 | 1 | 39 |
| 278 | 11 | Porcelain for Kings | 2019-06-15 | 12:15 | 40 | 3 | 3 | 37 |
| 279 | 11 | Porcelain for Kings | 2019-06-18 | 11:15 | 40 | 3 | 3 | 37 |
| 280 | 11 | Porcelain for Kings | 2019-06-29 | 11:30 | 40 | 2 | 2 | 38 |
| 281 | 11 | Porcelain for Kings | 2019-07-07 | 10:45 | 40 | 2 | 1 | 38 |
| 282 | 11 | Porcelain for Kings | 2019-07-07 | 11:00 | 40 | 4 | 0 | 36 |
| 283 | 11 | Porcelain for Kings | 2019-07-08 | 11:15 | 40 | 4 | 4 | 36 |
| 284 | 11 | Porcelain for Kings | 2019-07-13 | 12:45 | 40 | 2 | 2 | 38 |
| 285 | 11 | Porcelain for Kings | 2019-07-13 | 13:45 | 40 | 1 | 1 | 39 |
| 286 | 11 | Porcelain for Kings | 2019-07-14 | 12:00 | 40 | 1 | 1 | 39 |
| 287 | 11 | Porcelain for Kings | 2019-07-15 | 13:00 | 40 | 1 | 1 | 39 |
| 288 | 11 | Porcelain for Kings | 2019-07-16 | 12:30 | 40 | 1 | 1 | 39 |
| 289 | 11 | Porcelain for Kings | 2019-07-24 | 12:30 | 40 | 2 | 2 | 38 |
| 290 | 11 | Porcelain for Kings | 2019-07-24 | 17:15 | 40 | 1 | 1 | 39 |
| 291 | 11 | Porcelain for Kings | 2019-07-25 | 13:00 | 40 | 31 | 28 | 9 |
| 292 | 11 | Porcelain for Kings | 2019-07-28 | 11:00 | 40 | 4 | 4 | 36 |
| 293 | 11 | Porcelain for Kings | 2019-08-05 | 13:00 | 40 | 1 | 1 | 39 |
| 294 | 11 | Porcelain for Kings | 2019-08-07 | 16:00 | 40 | 4 | 4 | 36 |
| 295 | 11 | Porcelain for Kings | 2019-08-09 | 10:15 | 40 | 3 | 3 | 37 |
| 296 | 11 | Porcelain for Kings | 2019-08-09 | 13:00 | 40 | 1 | 1 | 39 |
| 297 | 11 | Porcelain for Kings | 2019-08-10 | 11:30 | 40 | 1 | 1 | 39 |
| 298 | 11 | Porcelain for Kings | 2019-08-14 | 14:45 | 40 | 3 | 2 | 37 |
| 299 | 11 | Porcelain for Kings | 2019-08-27 | 11:30 | 40 | 1 | 1 | 39 |
| 300 | 11 | Porcelain for Kings | 2019-09-11 | 12:45 | 40 | 5 | 5 | 35 |
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;