Reputation: 3
I have a table like this:
ID_ORIG ID_DEST DISTANCE
------- ------- --------
1 101 10
1 102 15
1 103 20
2 101 25
2 102 30
2 103 35
3 101 40
3 102 45
3 103 50
And I want the following result:
ID_ORIG 101 102 103
------- --- --- ---
1 10 15 20
2 25 30 35
3 40 45 50
I tried to use 'pivot', but obiously didn't achive this result. Database is Oracle 11g.
Any help would be appreciated.
Upvotes: 0
Views: 76
Reputation: 18639
Please try:
select * From(
select * from YourTable
) PIVOT (sum(DISTANCE) for (ID_DEST) IN (101, 102, 103));
Upvotes: 2