Curators with Multi-Visit Exhibits | Chill Interview
Curators with Multi-Visit Exhibits
Asked by:
MetaScreening
A museum network records visitor activity for exhibits managed by different curators. A separate catalog stores periodic snapshots of recognized exhibits.
The combination of visitor_id, curator_id, activity_date, and exhibit_id is the primary key. Each row records a visitor's number of visit events for one curator's exhibit on one date. Assume visit_events is nonnegative.
Table: exhibit_catalog
+-------------+--------------+
| Column Name | Type |
+-------------+--------------+
| exhibit_id | integer |
| wing | varchar(255) |
| record_date | date |
| opened_on | date |
| country | varchar(255) |
+-------------+--------------+
+-------------+--------------+
| Column Name | Type |
+-------------+--------------+
| exhibit_id | integer |
| wing | varchar(255) |
| record_date | date |
| opened_on | date |
| country | varchar(255) |
+-------------+--------------+
The combination of exhibit_id and record_date is the primary key. The catalog may contain multiple dated snapshots for the same exhibit.
An exhibit qualifies for a curator when both conditions are true:
The exhibit_id appears at least once in exhibit_catalog.
The sum of visit_events for that curator_id and exhibit_id is greater than 1.
Each curator-exhibit pair counts at most once, regardless of how many activity rows or catalog snapshots it has.
Count the curators who have more than three distinct qualifying exhibits—that is, at least four. Return one row with the result in a column named curator_count. If the input is empty or no curator qualifies, return 0.