Please help me undestand how order by influences to over clause. I have read msdn and one book and still misunderstood.
Let's say we have such query:
SELECT Count(OrderID) over(Partition By Year(OrderDate)),*
FROM [Northwind].[dbo].[Orders]
order by OrderDate
The result is that each raw has the column with the value how many entries in the table have the same year.
But what's happened when i try this query?:
SELECT ROW_NUMBER() over(Partition By Year(OrderDate)
order by OrderDate) as RowN,*
FROM [Northwind].[dbo].[Orders]
order by RowN
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.