I would like to count the number of sorted subgroups in the table below :
id nmb
1 11
2 12
3 13
4 22
5 23
6 31
7 32
8 33
9 11
10 12
11 13
12 12
13 13
14 21
15 22
16 11
17 12
18 13
19 14
And want to obtain something like this in postgresql 8.4 :
id nmb local
1 11 1
2 12 1
3 13 1
4 22 1
5 23 1
6 31 1
7 32 1
8 33 1
9 11 2
10 12 2
11 13 2
12 12 3
13 13 3
14 21 3
15 22 3
16 11 4
17 12 4
18 13 4
19 14 4
EDIT: the last few numbers on the 'local' column were wrong. Corrected!
Thank you.