title: Simulate rank in mysql (without rank) with two conditions
body: <p>Coming from this answer: <a href="https://stackoverflow.com/questions/26613999/rank-based-on-two-columns/26614886#comment95862818_26614886">Rank based on two columns</a></p>
  
  <p>I've the following example:</p>
  
  <pre><code>CREATE TABLE tmpPoradi 
      (`player` int, `wins` int, `diff` int)
  ;
  
  INSERT INTO tmpPoradi 
      (`player`, `wins`, `diff`)
  VALUES
      (1, 10, 12),
      (2, 8, 2),
      (3, 10, 10),
      (4, 8, 1),
      (5, 8, 7),
      (6, 10, 14),
      (8, 10, 10),
     (7, 12, 3)
  ;
  </code></pre>
  
  <p>and the desired result must be:</p>
  
  <pre><code>+--------+------+------+------+
  | player | wins | diff | rank |
  +--------+------+------+------+
  |      7 |   12 |    3 |    1 |
  |      6 |   10 |   14 |    2 |
  |      1 |   10 |   12 |    3 |
  |      3 |   10 |   10 |    4 |
  |      8 |   10 |   10 |    4 |
  |      5 |    8 |    7 |    5 |
  |      2 |    8 |    2 |    6 |
  |      4 |    8 |    1 |    7 |
  +--------+------+------+------+
  </code></pre>
  
  <p>The thing is that the original answer returns the row count:</p>
  
  <pre><code> SELECT player, wins, diff,rank from
   (
   SELECT player, wins, diff, @winrank := @winrank + 1 AS rank
   from tmpPoradi,(SELECT @winrank := 0) r 
   ORDER BY wins DESC,diff DESC
   )  rt
  ORDER BY rank 
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>+---------+-------+-------+-------+
  |  player |  wins |  diff |  rank |
  +---------+-------+-------+-------+
  |       7 |    12 |     3 |     1 |
  |       6 |    10 |    14 |     2 |
  |       1 |    10 |    12 |     3 |
  |       3 |    10 |    10 |     4 |
  |       8 |    10 |    10 |     5 |
  |       5 |     8 |     7 |     6 |
  |       2 |     8 |     2 |     7 |
  |       4 |     8 |     1 |     8 |
  +---------+-------+-------+-------+
  </code></pre>
  
  <p>and my attemp with conditions returns the following result: (dont know why)</p>
  
  <pre><code>  SELECT player, wins, diff,rank from
   (
   SELECT player, wins, diff, @winrank := IF(wins = diff,@winrank,@winrank + 1) AS rank
   from tmpPoradi,(SELECT @winrank := 0) r 
   ORDER BY wins DESC,diff DESC
   )  rt
  ORDER BY rank 
  
  
  +---------+-------+-------+-------+
  |  player |  wins |  diff |  rank |
  +---------+-------+-------+-------+
  |       7 |    12 |     3 |     1 |
  |       6 |    10 |    14 |     2 |
  |       3 |    10 |    10 |     3 |
  |       8 |    10 |    10 |     3 |
  |       1 |    10 |    12 |     3 |
  |       5 |     8 |     7 |     4 |
  |       2 |     8 |     2 |     5 |
  |       4 |     8 |     1 |     6 |
  +---------+-------+-------+-------+
  </code></pre>
  
  <p>so the question is:</p>
  
  <p><strong>What I'm doing wrong and how can achieve rank by wins and then if wins are tied, subrank by diff, and then if diff are tied, rank are the same?</strong></p>