title: Unite adjacent ranges from different rows in MySQL
body: <p>Suppose there is a company with several departments. Each of them has one or a few ranges of internal phone numbers assigned to it. Assignment is stored in one database table, but in different manner for different departments, like this:</p>
  
  <pre><code>dept_name    range_start    range_end
  
  Sales        10             19
  Sales        20             29
  HR           30             49
  Finance      60             65
  Finance      84             93
  </code></pre>
  
  <p>How can adjacent ranges be selected as united, so that for Sales dept. there will be just one row in results, like this:</p>
  
  <pre><code>dept_name    range_start    range_end
  
  Sales        10             29
  HR           30             49
  Finance      60             65
  Finance      84             93
  </code></pre>
  
  <p>?</p>