title: Overlapping Date Ranges Summarized
body: <p>​A parent company owns companies with employees.  Each company can hire and term an employee.<br>
  An employee can work for multiple companies at the same time.  </p>
  
  <p>Within a company, hire and term dates cannot overlap, but they can across companies.  A hire date is considered to be a person's first day of employment, and a term date is considered to be a person's last day of employment.  </p>
  
  <p>A person can have many periods of employment (leave and return).  Active employees have a term date of '9999-12-31'.</p>
  
  <p><strong>How do I get a result set of a person's hire and term dates for the parent company ignoring overlapping dates?</strong></p>
  
  <p>Source Table:</p>
  
  <pre><code>+--------------+----------+-------------+-------------+
  | ​employee_id  | company​  | hire_date​   |  term_date​  |
  +--------------+----------+-------------+-------------+
  | ​1            | A​        | 2017-01-01​  | 2017-07-01​  |
  | ​1            | A        | 2018-01-01​  | 2018-06-15​  |
  | ​1            | B​        | 2018-04-01​  | 9999-12-31​  |
  +--------------+----------+-------------+-------------+
  </code></pre>
  
  <p>Desired result:</p>
  
  <pre><code>+--------------+-------------+-------------+
  | ​employee_id  |  hire_date​  | term_date​   |
  +--------------+-------------+-------------+
  | ​1            | 2017-01-01​  | 2017-07-01​  |
  | ​1            | 2018-01-01​  | 9999-12-31​  |
  +--------------+-------------+-------------+
  </code></pre>