I am stuck with a weird problem of handling data sequences. My source data looks like -
Roll-on, Marker
1,1
2,0
3,0
5,1
8,1
9,0
10,1
the marker column can only have two values, 1 and 0
if the roll no column is in a sequence, the marker value of 1 indicates the start of the sequence and all the remaining roll no will have marker value 0 within that sequence. So for roll no sequence 1-3, marker value is 1 for roll no 1 and 0 for the rest. However, if roll no doesn't fall into a sequence(as in roll no 8), the marker value is 1. From this data I need to create an output as follows -
Roll range
1
2
3
1-3
5
5-5
8
9
10
8-10
Meaning -
- display the roll no in sequence as in the input
- after each sequence ends, display a new record containing the start and end roll no of the proceeding sequence
How is this possible?
Thanks in advance for help.
sqlsays: "...and a tag for the DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, etc.) being used." Please correct the tags8-10? ( Because 8 was not "in a sequence" )8-10instead of8-9and10-10? because there are twoMarker