Skip to content
Advertisement

Parent child relationship Join tables in oracle sql

I have a requirement below.

Table Structure containing Position details

Now I have to get output like below

enter image description here

How can this be achieved ? I have written the below SQL but parent_position_id is coming, not parent_position_code

Should I write a sub query? How should I proceed ? This is Oracle SQL

Thanks, Shivam

Advertisement

Answer

Noone ever said you could only join a table in once:

Bear it in mind; I see people coming to thinking all the time that they can only join a table once. If one table decodes a value in 3 different columns, then you sure can join that same table in 3 times… Imagine if it were an address table, and a Student had a HomeAddressId, WorkAddressId and StudyAddressId, and the Address table held all these addresses – you’d join the addresses table to the Student table 3 times to get all the data..

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