You're managing a venue booking system for a conference center with multiple halls. Each hall can host events, and sometimes bookings overlap or are scheduled back-to-back. Your task is to merge all overlapping events within the same hall to get a clear picture of actual venue usage.
Given a table HallEvents with columns:
hall_id(int): The hall identifierstart_day(date): Event start dateend_day(date): Event end date
Two events overlap if they have at least one day in common. For example, an event from Jan 1-3 overlaps with an event from Jan 3-5 (they share Jan 3).
Your goal: Write a SQL solution to merge all overlapping events in the same hall and return the consolidated booking periods.
Note: The table may contain duplicate rows, and events are only merged if they're in the same hall.
Input & Output
Constraints
- 1 โค Number of rows โค 104
- 1 โค hall_id โค 100
- start_day โค end_day
- Table may contain duplicate rows
- Events overlap if they share at least one day