I have raw data as below in source table. i need this transformed as shown below.
| user_id | domain_id | id_value | id_status |
|---|---|---|---|
| 48085640 | ID1 | 21885688845 | 5 |
| 48085640 | ID1 | 20544518912 | 5 |
| 48085640 | ID2 | 176652329 | 5 |
| 48085640 | ID2 | 121702229 | 5 |
| 48085640 | ID3 | 111844976 | 5 |
| 48085640 | ID3 | 111347117 | 5 |
| 48085640 | ID4 | 1234567 | 5 |
And i am trying to achieve the output as below. There are two values for ID1, ID2, ID3. if i use pivot i must use an aggregate function like max() or min() i am losing one of the rows.also i need to fetch the ID1, ID2 and ID3 only and filter rest of the IDs. Please help me achieve this in oracle sql and also in impala if possible
| user_id | ID1 | ID2 | ID3 | id_status |
|---|---|---|---|---|
| 48085640 | 218856888 | 1766523293 | 111844976 | 5 |
| 48085640 | 205445189 | 1217022297 | 111347117 | 5 |