title: Minimum number of Meeting Rooms required to Accomodate all Meetings in MySQL
body: <p>I have the following columns in a table called meetings: meeting_id - int, start_time - time, end_time - time. Assuming that this table has data for one calendar day only, how many minimum number of rooms do I need to accomodate all the meetings. Room size/number of people attending the meetings don't matter.</p>
  
  <p>Here's the solution:</p>
  
  <pre><code>select * from
  (select t.start_time, 
          t.end_time, 
          count(*) - 1 overlapping_meetings, 
          count(*) minimum_rooms_required,
          group_concat(distinct concat(y.start_time,' to ',t.end_time) 
  separator ' // ') meeting_details from 
  (select 1 meeting_id, '08:00' start_time, '09:15' end_time union all
  select 2, '13:20', '15:20' union all
  select 3, '10:00', '14:00' union all
  select 4, '13:55', '16:25' union all
  select 5, '14:00', '17:45' union all
  select 6, '14:05', '17:45') t left join 
  
  (select 1 meeting_id, '08:00' start_time, '09:15' end_time union all
  select 2, '13:20', '15:20' union all
  select 3, '10:00', '14:00' union all
  select 4, '13:55', '16:25' union all
  select 5, '14:00', '17:45' union all
  select 6, '14:05', '17:45') y
  
  on t.start_time between y.start_time and y.end_time
  
  group by start_time, end_time) z;
  </code></pre>
  
  <p>My question - <em>is there anything wrong with this answer? Even if there's nothing wrong with this, can someone share a better answer?</em></p>