title: Usage of Apache Pig rank function
body: <p>Am using Pig 0.11.0 rank function and generating ranks for every id in my data.
  I need ranking of my data in a particular way. I want the rank to reset and start from 1 for every new ID.</p>
  
  <p>Is it possible to use the rank function directly for the same?
  Any tips would be appreciated.</p>
  
  <p>Data:</p>
  
  <pre><code>id,rating
  X001, 9
  X001, 9
  X001, 8
  X002, 9
  X002, 7
  X002, 6
  X002, 5
  X003, 8
  X004, 8
  X004, 7
  X004, 7
  X004, 4
  </code></pre>
  
  <p>On using rank function like:
  op = rank data by id,score;</p>
  
  <p>I get this output</p>
  
  <pre><code>rank,id,rating
  1, X001, 9
  1, X001, 9
  2, X001, 8
  3, X002, 9
  4, X002, 7
  5, X002, 6
  6, X002, 5
  7, X003, 8
  8, X004, 8
  9, X004, 7
  9, X004, 7
  10, X004, 4
  </code></pre>
  
  <p>Desired O/P:</p>
  
  <pre><code>rank,id,rating
  1, X001, 9
  1, X001, 9
  2, X001, 8
  1, X002, 9
  2, X002, 7
  3, X002, 6
  4, X002, 5
  1, X003, 8
  1, X004, 8
  2, X004, 7
  2, X004, 7
  3, X004, 4
  </code></pre>