Perhaps this will help you:
select 'id', LISTAGG(id, ' ') WITHIN GROUP (ORDER BY name) from testtable union select 'name', LISTAGG(name, ' ') WITHIN GROUP (ORDER BY name) from testtable
EDIT:
or with an axis:
create table TestTable2 (id varchar2(30), name varchar2(10)); insert into TestTable2 values ('id', 'name'); insert into TestTable2 select cast(id as varchar2(30)) as id , name from testtable select * from testtable2 pivot ( max(name) for id in ('id',1,2,3,4) )
source share