Skip to content
Advertisement

Hierarchy data from Oracle from Multiple Tables

I’m trying to return calendar hierarchy from my table. Year -> Quarter – > Month

Since, I don’t have Id & parent Id mapping in my table, I’m using ROW_NUMBER() concept to map relative data and using UNION listing hierarchical data with different columns.

Here’s my code:

But I wanted data as below,

How can I achieve this using my Query? Please help on this.

Advertisement

Answer

Depending on the column week_date_date you can construct such an unpivoting query :

Demo

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