I'm at a loss how to accomplish this. We have a legacy (control) file that contains 4 columns. Category, Value, Sequence, and Data. I'm trying to create an SQL View that will contain the necessary data in ONE row with multiple columns.
For a given Category, Value and Sequence, the Data field (40 characters) contains information that I need to place in separate columns using SUBSTR.
The challenge occurs when I have multiple rows (i.e. sequence 1, 2, and 3) and I need to substring Data into multiple columns from each of them.
WWCAT WWSLC WWSQ2 WWDTA
0026 AAA 1 001 AMANDA GRASSER
0026 AAA 2 NON001
In the example data above, I need to create ONE row containing
WWSLC as column1
substr(WWDTA, 5, 25) when WWSQ2=1 as column 2
substr(WWDTA, 6, 3) when WWSQ2=2 as column 3
substr(WWDTA, 9, 3) when WWSQ2 =2 as column 4
I've tried subselects, but I'm hoping there is a more "elegant" method.
Thx,
Greg
For a given Category, Value and Sequence, the Data field (40 characters) contains information that I need to place in separate columns using SUBSTR.
The challenge occurs when I have multiple rows (i.e. sequence 1, 2, and 3) and I need to substring Data into multiple columns from each of them.
WWCAT WWSLC WWSQ2 WWDTA
0026 AAA 1 001 AMANDA GRASSER
0026 AAA 2 NON001
In the example data above, I need to create ONE row containing
WWSLC as column1
substr(WWDTA, 5, 25) when WWSQ2=1 as column 2
substr(WWDTA, 6, 3) when WWSQ2=2 as column 3
substr(WWDTA, 9, 3) when WWSQ2 =2 as column 4
I've tried subselects, but I'm hoping there is a more "elegant" method.
Thx,
Greg
Comment