title: how to give same serial number for group of records in mysql
body: <p>I am just new in mysql. I have records like below in carts table</p>
  
  <pre><code> id   code
   1     100
   2     101
   3     102
   4     100
   5     100
   6     101
  </code></pre>
  
  <p>My excepted output like below:-</p>
  
  <pre><code>id     code    serial_number
   1     100        1
   2     101        2
   3     102        3
   4     100        1
   5     100        1
   6     101        2
  </code></pre>
  
  <p>I want same serial number that is belongs to same group i.e code. can anyone help me how to do?</p>