Skip to content
Advertisement

How to joins in oracle based on condition

I have two tables as below:

Table Apple:

Table KEEY:

Desired Output:

Code Tried So far:

This is giving me :

I guess i need to use pivot instead of Union to get both the ids on same row.

Have you ever encountered such scenarios? Any pointers to proceed will be very helpful.

Thanks in Advance!

DDL used for the above problem:

Advertisement

Answer

I think you just want two joins:

Here is a db<>fiddle (it uses Postgres just because that is easier to set up in the fiddle, but the results should be the same).

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