View
slot_availability
Booked, admitted and remaining places for every dated slot. Replaces the stored 2020 count.
Rows 1–25 of 443
| slot_idINTEGER | exhibition_idINTEGER | titleTEXT | slot_dateTEXT | start_timeTEXT | capacityINTEGER | bookedany | admittedany | remainingany |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Treasures of the Royal Wardrobe | 2015-03-23 | 11:00 | 45 | 1 | 1 | 44 |
| 2 | 1 | Treasures of the Royal Wardrobe | 2015-03-23 | 12:30 | 45 | 1 | 0 | 44 |
| 3 | 1 | Treasures of the Royal Wardrobe | 2015-03-23 | 14:00 | 45 | 1 | 0 | 44 |
| 4 | 1 | Treasures of the Royal Wardrobe | 2015-03-31 | 15:45 | 45 | 2 | 2 | 43 |
| 5 | 1 | Treasures of the Royal Wardrobe | 2015-04-04 | 12:00 | 45 | 2 | 2 | 43 |
| 6 | 1 | Treasures of the Royal Wardrobe | 2015-04-25 | 11:30 | 45 | 45 | 41 | 0 |
| 7 | 1 | Treasures of the Royal Wardrobe | 2015-04-25 | 11:45 | 45 | 13 | 12 | 32 |
| 8 | 1 | Treasures of the Royal Wardrobe | 2015-05-21 | 13:15 | 45 | 1 | 1 | 44 |
| 9 | 1 | Treasures of the Royal Wardrobe | 2015-05-22 | 16:00 | 45 | 3 | 3 | 42 |
| 10 | 1 | Treasures of the Royal Wardrobe | 2015-05-25 | 12:15 | 45 | 5 | 5 | 40 |
| 11 | 1 | Treasures of the Royal Wardrobe | 2015-05-28 | 11:00 | 45 | 45 | 30 | 0 |
| 12 | 1 | Treasures of the Royal Wardrobe | 2015-05-28 | 11:15 | 45 | 2 | 2 | 43 |
| 13 | 1 | Treasures of the Royal Wardrobe | 2015-06-07 | 12:00 | 45 | 2 | 0 | 43 |
| 14 | 1 | Treasures of the Royal Wardrobe | 2015-06-11 | 17:15 | 45 | 1 | 1 | 44 |
| 15 | 1 | Treasures of the Royal Wardrobe | 2015-06-14 | 16:30 | 45 | 5 | 5 | 40 |
| 16 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-09-27 | 16:45 | 40 | 2 | 2 | 38 |
| 17 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-10-04 | 11:30 | 40 | 2 | 2 | 38 |
| 18 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-10-07 | 15:15 | 40 | 2 | 2 | 38 |
| 19 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-10-11 | 11:45 | 40 | 4 | 3 | 36 |
| 20 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-10-26 | 12:45 | 40 | 2 | 2 | 38 |
| 21 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-10-30 | 12:45 | 40 | 1 | 1 | 39 |
| 22 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-11-06 | 12:15 | 40 | 1 | 1 | 39 |
| 23 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-11-10 | 15:30 | 40 | 3 | 3 | 37 |
| 24 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-11-18 | 10:30 | 40 | 4 | 3 | 36 |
| 25 | 2 | Bronze and Fire: Renaissance Sculpture | 2015-11-18 | 14:45 | 40 | 1 | 0 | 39 |
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;