View
slot_availability
Booked, admitted and remaining places for every dated slot. Replaces the stored 2020 count.
Rows 426–443 of 443
| slot_idINTEGER | exhibition_idINTEGER | titleTEXT | slot_dateTEXT | start_timeTEXT | capacityINTEGER | bookedany | admittedany | remainingany |
|---|---|---|---|---|---|---|---|---|
| 426 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-05 | 13:45 | 45 | 4 | 4 | 41 |
| 427 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-08 | 10:30 | 45 | 1 | 1 | 44 |
| 428 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-09 | 10:00 | 45 | 2 | 2 | 43 |
| 429 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-09 | 17:15 | 45 | 1 | 1 | 44 |
| 430 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-11 | 11:30 | 45 | 2 | 2 | 43 |
| 431 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-11 | 15:00 | 45 | 2 | 2 | 43 |
| 432 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-15 | 10:30 | 45 | 1 | 1 | 44 |
| 433 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-15 | 12:45 | 45 | 3 | 3 | 42 |
| 434 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-17 | 12:00 | 45 | 3 | 3 | 42 |
| 435 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-17 | 12:15 | 45 | 2 | 2 | 43 |
| 436 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-17 | 13:15 | 45 | 1 | 1 | 44 |
| 437 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-18 | 12:00 | 45 | 2 | 2 | 43 |
| 438 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-18 | 14:45 | 45 | 1 | 1 | 44 |
| 439 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-19 | 17:15 | 45 | 2 | 2 | 43 |
| 440 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-22 | 11:15 | 45 | 2 | 1 | 43 |
| 441 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-23 | 11:30 | 45 | 2 | 2 | 43 |
| 442 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-23 | 16:15 | 45 | 4 | 3 | 41 |
| 443 | 12 | Leonardo da Vinci: 500th Anniversary | 2020-02-24 | 13:15 | 45 | 4 | 4 | 41 |
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;