title: Mysql RANK is not giving RANK for each category
body: <p>I tried following thing but it is not ranking each category wise. Instead giving rank for all records without considering category. I want the RANK to re-occur for each category</p>
  
  <pre><code>select  rs.Section,rs.Field1,rs.Field2 , 
  @curRank := @curRank + 1 AS rank 
  from (
  select rs.Field1,rs2.Field2 
  from table rs
  inner join table2 rs2 on rs.Field1=rs2.Field1
  group by rs.Section,rs.Field1 
  )rs,  (SELECT @curRank := 0) r
  </code></pre>
  
  <p><strong>Actual Output:</strong> (From Mysql Output )</p>
  
  <pre><code>Category Field1 Field2 Rank
  Male     10     10     1
  Male     11     10     2
  Male     12     10     3
  ....
  FeMale   10     10     11
  FeMale   11     10     12
  FeMale   12     10     13
  ....
  </code></pre>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code>Category Field1 Field2 Rank
  Male     10     10     1
  Male     11     10     2
  Male     12     10     3
  ....
  FeMale   10     10     1
  FeMale   11     10     2
  FeMale   12     10     3
  ....
  </code></pre>