这是我目前的数据
FileNumber | Type | PerYear | PerMonth
L200200 Boat 2013 1
L303000 Boat2 2013 1
L400400 Yack 2013 2
L500500 Comp 2013 2
L600600 Item 2013 3
...
L909000 Chair 2014 1
X900220 Battle 2014 2
我想要一个基于 PerYear 和 PerMonth 的 Identity(counter) 列的查询这是我想要的结果
KindOFIdentity FileNumber | Type | PerYear | PerMonth
1 L200200 Boat 2013 1
1 L303000 Boat2 2013 1
2 L400400 Yack 2013 2
2 L500500 Comp 2013 2
3 L600600 Item 2013 3
4 ...
5 ...
6 ...
7 ...
8 ...
9 ...
10 ...
11 ...
12 ...
13 L909000 Chair 2014 1
14 X900220 Battle 2014 2
下面的查询没有给我正确的结果。
Select ROW_NUMBER() over (partition by PerYear,PerMonth order by PerYear, PerMonth) AS KindOFIdentity, Type, PerYear, PerMonth
from MyTable