Skip to content
Advertisement

Parse xmltype into table after pivot xml

i have return XMLTYPE after pivot xml that looks like

i need to get table that will look like

Advertisement

Answer

You can get the country value with this XPath expression:

And a similar one for the population. Giving:

But if you want a column for each country, from here you still need to pivot the data to get the result!

Which begs the question:

Why use an XML pivot?

If it’s because you don’t know the country names and are doing something like:

This hasn’t saved you anything! You still need to know the country names to get the output as columns.

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