I need to create a sequence number for certain rows that are pulled from a raw data file that I'm getting. Here is the situation. I have a data file with about 3 million rows, which I’m able to process into various tables. However, I need to give certain rows a sequence number, basically a Grandparent to Parent to Child relationship.
Here is the scenario, I have 10 rows
5701_012345678_1000 -- This row needs to have a sequence number of 1… Example: 00001
6701_012345678_ABCDE – This row needs to have a its own sequence number of 1 and the number 1 from the previous 5701 row Example: 00001_00001
3102_012345678_4565465afdasfd -- The row needs to be the combination of the first and second row and its own number. Example: 00001_00001_00001
2302 --- Gets none of the sequence numbers
6701_012345678_2000 – This row needs to be a number 2 but still the number 1 from the first 5701 record, since we have not gotten to a new 5701 record; Example: 00001_00002
3102_012345678_ldskfjladjlfdjl --- This row gets the number 2 from the 6701 row above but still the number 1. Example: 00001_00002_00001
5701_987654321_1000 --- This gets the next number of 2. 00002
2302_987654321_dshfkjadhfkl – Nothing
5701_234567890_1000 --- Number 3: 00003
5701_345678901_1000 --- Number 4: 00004
6701_345678901_ABCDE --- Number 1 for it being a new 6701 record under a new 5701 record and the number 4 from the last. Example: 00004_00001
So any row starting with 5701 is the grandparent, if the 5701row has any 6701 (parent) rows, they will follow immediately after and finally if the 6701 row has any 2013 (child) rows they will follow immediately after the 6701 row and then the process could start over with the very next row or 20 rows later.
Any assistance in finding the code that would help me with this is greatly appreciated
Here is the scenario, I have 10 rows
5701_012345678_1000 -- This row needs to have a sequence number of 1… Example: 00001
6701_012345678_ABCDE – This row needs to have a its own sequence number of 1 and the number 1 from the previous 5701 row Example: 00001_00001
3102_012345678_4565465afdasfd -- The row needs to be the combination of the first and second row and its own number. Example: 00001_00001_00001
2302 --- Gets none of the sequence numbers
6701_012345678_2000 – This row needs to be a number 2 but still the number 1 from the first 5701 record, since we have not gotten to a new 5701 record; Example: 00001_00002
3102_012345678_ldskfjladjlfdjl --- This row gets the number 2 from the 6701 row above but still the number 1. Example: 00001_00002_00001
5701_987654321_1000 --- This gets the next number of 2. 00002
2302_987654321_dshfkjadhfkl – Nothing
5701_234567890_1000 --- Number 3: 00003
5701_345678901_1000 --- Number 4: 00004
6701_345678901_ABCDE --- Number 1 for it being a new 6701 record under a new 5701 record and the number 4 from the last. Example: 00004_00001
So any row starting with 5701 is the grandparent, if the 5701row has any 6701 (parent) rows, they will follow immediately after and finally if the 6701 row has any 2013 (child) rows they will follow immediately after the 6701 row and then the process could start over with the very next row or 20 rows later.
Any assistance in finding the code that would help me with this is greatly appreciated