title: SQL SERVER - Rank/Row Number through months
body: <p>I have query which outputs the following, </p>
  
  <pre>
  RegDate     Month      countrycode  affiliate sk_skin  AC    GameWin
  1/1/2011    1/1/2011   DE           0         a        274   32458.2558
  1/1/2011    1/1/2011   UK           0         b        4     386.6925
  1/1/2011    1/1/2011   FI           1         a        320   12875.0189
  1/1/2011    1/1/2011   SK           1         b        85    5752.8503
  1/1/2011    1/1/2011   FI           0         a        520   65339.3142
  1/1/2011    1/1/2011   FI           1         a        295   29163.1045
  1/1/2011    2/1/2011   DE           0         a        79    16028.3849
  1/1/2011    3/1/2011   DE           0         b        4     525.252
  1/1/2011    3/1/2011   DE           1         a        36    7718.6327
  1/1/2011    3/1/2011   DE           1         b        24    5715.1279
  1/1/2011    4/1/2011   FI           0         a        196   27357.4072
  1/1/2011    4/1/2011   FI           1         a        146   20178.9315
  </pre>
  
  <p>I would like to have a Month row number, in this case 1/1/2011 will be 1, 2/1/2011 will be 2, 3/1/2011 will be 3, 4/1/2011 will be 4. </p>
  
  <p>This query will be running through a loop so the month could start at different points, </p>
  
  <p>I would like the following output; </p>
  
  <pre>
  RegDate   Month      countrycode  affiliate  sk_skin  AC   GameWin      Month
  1/1/2011  1/1/2011   DE           0          a        274  32458.2558   1
  1/1/2011  1/1/2011   UK           0          b        4    386.6925     1
  1/1/2011  1/1/2011   FI           1          a        320  12875.0189   1
  1/1/2011  1/1/2011   SK           1          b        85   5752.8503    1
  1/1/2011  1/1/2011   FI           0          a        520  65339.3142   1
  1/1/2011  1/1/2011   FI           1          a        295  29163.1045   1
  1/1/2011  2/1/2011   DE           0          a        79   16028.3849   2
  1/1/2011  3/1/2011   DE           0          b        4    525.252      3
  1/1/2011  3/1/2011   DE           1          a        36   7718.6327    3
  1/1/2011  3/1/2011   DE           1          b        24   5715.1279    3
  1/1/2011  4/1/2011   FI           0          a        196  27357.4072   4
  1/1/2011  4/1/2011   FI           1          a        146  20178.9315   4
  </pre>
  
  <p>I have tried to use the following, </p>
  
  <pre><code>(RANK() OVER (ORDER BY DATEADD(m,DATEDIFF(m,0,date),0))-1) as rank
  </code></pre>
  
  <p>The format of the date is date (no time) using</p>
  
  <pre><code>DATEADD(m,DATEDIFF(m,0,datetime),0)
  </code></pre>
  
  <p>This rank gives me random Rank number (with a sort of pattern), however since this query will be added to a loop and iterated over the number generated needs to be, 1 for lowest month, 2 for second lowest ect... </p>
  
  <p>I hope i have explained myself properly. </p>