pivot - Convert rows to columns oracle SQL -


i did not find suitable previous answers hence posting question. need convert rows columns. pivot examples convert rows single column whereas requirement multiple columns. table looks this

type     id test1    10 test1    20 test1    30 test2    10 test2    40 

i be

type       id        type      id test1      10       test2      10 test1      20       test2      40 test1      30 

appreciate suggestions/inputs!

you enumerate rows row_number() , make pivot:

sqlfiddle demo

select *    (     select d.*, row_number() over(partition type order id) rn data d)   pivot (max(type) type, max(id) id type in ('test1' t1, 'test2' t2)) 

Comments