Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

self join ! get output without using any loop

3565694Jan 29 2019 — edited Jan 29 2019

Hello friends ,

First of all.

I am working on production environment (Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production)  and that's why i can't create any DB object like DBLINK or function etc.

Now I am supposed to write a sql query to fetch some data from few tables.

I have completed every part of the query except this one.

here we have a table like :

COLACOLB
A1B1
B1C1
C1D1
D1E1
A2B2
B2C2
AABB
BBYY
YYSS
SSZZ
ZZNN
NNHH

Requirement here is to pass one value to cola in the query like cola = 'A1' and it should return 'E1' , if i am passing value as cola = 'C1' then still I should get 'E1' as output.

same with other rows

COLA = 'A1' output : 'E1'

COLA = 'B1' output : 'E1'

COLA = 'C1' output : 'E1'

COLA = 'D1' output : 'E1'

COLA = 'A2' output : 'C2'

COLA = 'B2' output : 'C2'

COLA = 'AA' output : 'HH'

COLA = 'BB' output : 'HH'

COLA = 'YY' output : 'HH'

COLA = 'SS' output : 'HH'

COLA = 'ZZ' output : 'HH'

COLA = 'NN' output : 'HH'

Note: we will pass only one value at a time and it will be for COLA . we can not create any DB object or anonymous block. Apart from that , we are free to use any system defined function.

Please help me to solve this issue I am way much close to the dead line and still can't find any logic.

This post has been answered by Saubhik on Jan 29 2019
Jump to Answer
Comments
Post Details
Added on Jan 29 2019
5 comments
463 views