Performing a complete transposition of rows into columns requires a combination of operations.
The input file presents coverage types as columns, so there is one row per policy number and two columns for every coverage type, since premium and commission is stated for each coverage type.
Input |
||||
Policy ID |
Corporate Property Premium |
Retail Property Premium |
Corporate Property Commission |
Retail Property Commission |
P-123 |
5000 |
1000 |
500 |
50 |
The desired output table presents coverage codes as rows with a premium and commission value for each.
Output |
|||
Policy ID |
COVERAGE_ID |
Premium |
Commission |
P-123 |
CORP_PROP |
5000 |
500 |
P-123 |
RET_PROP |
1000 |
50 |
LEFT(COVERAGE_ID, LENGTH(COVERAGE_ID)-5)