I have a table that looks like this:
GroupId | GroupKey |
---|---|
19 | |1083-0.0000|1137-0.0000 |
20 | |1090-0.0000|955-0.0000|954-0.0000|18-0.0000 |
21 | |1096-0.0000 |
22 | |1100-0.0000|838-0.0000|487-0.0000 |
23 | |1108-0.0000|56-0.9451|955-0.0000|12-0.0000|13-0.6800 |
I need to convert this table into looking like this:
GroupId | OrderId | OrderPercent | OrderSequence |
---|---|---|---|
19 | 1083 | 0.0000 | 1 |
19 | 1137 | 0.0000 | 2 |
20 | 1090 | 0.0000 | 1 |
20 | 955 | 0.0000 | 2 |
20 | 954 | 0.0000 | 3 |
20 | 18 | 0.0000 | 4 |
21 | 1096 | 0.0000 | 1 |
22 | 1100 | 0.0000 | 1 |
22 | 838 | 0.0000 | 2 |
22 | 487 | 0.0000 | 3 |
23 | 1108 | 0.0000 | 1 |
23 | 56 | 0.9451 | 2 |
23 | 955 | 0.0000 | 3 |
23 | 12 | 0.0000 | 4 |
23 | 13 | 0.6800 | 5 |
I can see how I can parse this out, but not how I can work with it on a set basis. (I could just use a cursor, but I would rather not.)
What sql would be needed to convert the GroupKey values into their own columns?