Hi All,
I have the following table:
declare @T table
(
ID int identity
, NUM int
);
insert into @T values
(0),(0),(0),(1),(1),(0),(0),(0),(1),(1),(0),(0),(0);
ID NUM
1 0
2 0
3 0
4 1
5 1
6 0
7 0
8 0
9 1
10 1
11 0
12 0
13 0
I would like to rank each group in NUM column,like this
ID NUM Rank
1 0 1
2 0 1
3 0 1
4 1 2
5 1 2
6 0 3
7 0 3
8 0 3
9 1 4
10 1 4
11 0 5
12 0 5
13 0 5
I tried to use DENSE_RANK(),RANK() but no luck.Any Ideas?
BTW i posted on T_SQl 2008 forum as well
Thank you advance