title: TSQL: over clause
body: <p>Please help me undestand how <strong>order by</strong> influences to over clause. I have read msdn and one book and still misunderstood.</p>
  
  <p>Let's say we have such query:</p>
  
  <pre><code>SELECT Count(OrderID) over(Partition By Year(OrderDate))
        ,*
  FROM [Northwind].[dbo].[Orders]
  ORDER BY OrderDate
  </code></pre>
  
  <p>The result is that each raw has the column with the value how many entries in the table have the same year. </p>
  
  <p><a href="http://img-fotki.yandex.ru/get/3912/svin80.2/0_3b871_3bb591da_XL" rel="nofollow noreferrer">alt text http://img-fotki.yandex.ru/get/3912/svin80.2/0_3b871_3bb591da_XL</a></p>
  
  <p>But what's happened when i try this query?:</p>
  
  <pre><code>SELECT ROW_NUMBER() over(Partition By Year(OrderDate)
                           order by OrderDate) as RowN
        ,*
  FROM [Northwind].[dbo].[Orders]
  ORDER BY RowN
  </code></pre>
  
  <p><a href="http://img-fotki.yandex.ru/get/3908/svin80.2/0_3b872_c9352fb1_XL" rel="nofollow noreferrer">alt text http://img-fotki.yandex.ru/get/3908/svin80.2/0_3b872_c9352fb1_XL</a></p>
  
  <p>Now I see the only thing that each RowN has 3 different years for each value (1996, 1997, 1998). I expected that RowN will be the same value for all 1996 year dates. Please explain me what happens and why.</p>