I have a table structue which has 2 columns as mentioned below
Column_name old Value New_Value
:--------- :------- :---------
Name NULL John
Age NULL 45
Status Active Inactive
I need a output like
John Name
45 Age
Inactive Status
Could you please help me out here.
Looks like a NVL
to me... Sample data in lines #1 - 5; query that does it begins at line #6.
SQL> with test (column_name, old_value, new_value) as
2 (select 'Name' , null , 'John' from dual union all
3 select 'Age' , null , '45' from dual union all
4 select 'Status', 'Active', 'Inactive' from dual
5 )
6 select nvl(new_value, old_value) value,
7 column_name
8 from test;
VALUE COLUMN
-------- ------
John Name
45 Age
Inactive Status
SQL>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.