Combining rows
Guys,
I have the followning requirement. Please see the follwing eg.
I have the following rows and columns in a table
ID CLASS PRODUCT CATEGORY SALE REBATES
1001 A4T ABC W_SALE 100 23
1001 A4T ABC RETAIL 345 45
1003 B6Y XYZ W_SALE 676 123
1004 V8U CVZ RETAIL 500 110
I want to insert the data inot another table .
If there are two rows with same ID,CLASS and PRODUCT but with different CATEGORY then I want to combine these two rows and put the respctive values of
two different category into additional columns.
The ideal output should be as given below
ID CLASS PRODUCT W_SALE RET_SALE W_REBATE RET_REBATE
1001 A4T ABC 100 345 23 45 --combined row
1003 B6Y XYZ 676 NULL 123 NULL
1004 V8U CVZ NULL 500 NULL 110
Here the first two rows are combined by taking common ID,CLASS,PRODUCT and then the values
are taken to two additional columns. If there is no two rows with same ID,CLASS and PRODUCT then only the values with respect
to the CATEGORY will go to the respective columns and other columns are kept null.
Is there any way I can do it with some analytical functions.
Thanks in advance