title: Segmented group in MySQL
body: <p>How I can to group <strong><em>continuous</em></strong> data in MySQL table and store its number to an extra column?</p>
  
  <p>For example:</p>
  
  <pre><code>id, n
  
  1   10
  2   10
  3   10
  4   56
  5   10
  6   10
  7   80
  8   12
  </code></pre>
  
  <p>I want to get something like this. Notice that n of 10 is listed <strong><em>twice.</em></strong></p>
  
  <pre><code>id   n   cnt
   1   10   3
   4   56   1
   5   10   2
   7   80   1
   8   12   1
  </code></pre>
  
  <p>Is that any way to do this without FUNCTION?</p>