Skip to content
Advertisement

Oracle: transpose table

I’ve got the following query

AND I’d like something like

Which outputs the same as

I’d like it to swap lines with columns.

Advertisement

Answer

Using dbms_xmlgen.getxmltype and XMLTABLE:

db<>fiddle demo

Advantage over unpivot – there is no need to specify column list in advance

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement