Skip to content
Advertisement

How to extract a hierarchical structure from a flat table?

I want to extract a hierarchical structure from a table in the oracle database. Table look like this:

That’s what I want to get:

I read about Oracle Hierarchical Queries, but i have no idea how to made it with my table structure… Finally, I have to get JSON to display on the web page. I prepared a table on sqlfiddle for convenience

I would be grateful for the help, any ideas?

Advertisement

Answer

One way is the following (using UNPIVOT):

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