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!

one column multiple alias names (conditional based)

mist123Jul 28 2020 — edited Jul 28 2020

Hi All,

I have data like below in the table

select 111 inv_no,100 cust_id, 'ABC' att_cat, 'ABC_1' att1 from dual

union all

select 222 inv_no,200 cust_id, 'BBB' att_cat, 'BBB_1' att1 from dual

union all

select 333 inv_no,300 cust_id, 'CCC' att_cat, 'CCC_1' att1 from dual

I want to populate columns as below.

if att_cat ='ABC' then att1 -- column name should be rev_att1

if att_cat ='BBB' then att1 -- column name should be rec_att1

if att_cat ='CCC' then att1 -- column name should be adj_att1

As well i want to populate like below.

if att_cat ='ABC' or att_cat ='BBB' or att_cat ='C' then att1

how to write in one-row query?

Oracle version: 11.2.4

Thanks

This post has been answered by Frank Kulash on Jul 28 2020
Jump to Answer
Comments
Post Details
Added on Jul 28 2020
6 comments
1,513 views