1

Topic: Numbering of identical lines

If  to do that enumerates
1 1
1 2
2 1
3 1
3 2
4 1
1 3
2 2
3 3
4 2
AND IT IS NECESSARY TO ME
1 1
1 2
2 1
3 1
3 2
4 1
1 1
2 1
3 1
4 1
that were numbered only  lines if there is a rupture that numbering began with the beginning

2

Re: Numbering of identical lines

WITH T AS (SELECT * FROM (VALUES
(1,1)
,(2,1)
,(3,4)
,(4,3)
,(5,3)
,(6,2)
,(7,1)
,(8,2)
,(9,3)
,(10,4)
,(11,4)) T (id, x))
,D AS (SELECT N=ROW_NUMBER () OVER (ORDER BY id)-ROW_NUMBER () OVER (PARTITION BY x ORDER BY id), * FROM T)
SELECT id, x, N, y=ROW_NUMBER () OVER (PARTITION BY N, x ORDER BY x)
FROM D
ORDER BY id;

3

Re: Numbering of identical lines

kolyady;
The rights of Shyfl. What defines such sequence of records?
I here specially for a field id in the answer invented.

4

Re: Numbering of identical lines

iap;
Thanks really gained, I already try to enumerate a floor of day

5

Re: Numbering of identical lines

kolyady;
It was necessary not to think, and to google ISLANDS and GAPS. To this problem already from fifty years.