We help IT Professionals succeed at work.

Oracle SQL select stmt

mrong
mrong asked
on
Greeting,
Below are the table structure and sample data in Oracle
ID  ID_level1 Level1_desc ID_level2 Level2_desc ID_level3 Level3_desc ID_level4 Level4_desc ID_level5 Level5_desc  
100   100        dept1     null      null         null         null     null       null       null      null
101   100        dept1      101       dept2       null         null     null       null       null      null
102   100        dept1      101       dept2       102          dept3    null       null       null      null

Below is the output I need.
ID   desc
100  dept1
101  dept2
102  dept3

Could someone suggest a select stmt?

Thanks.
Comment
Watch Question

"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
Commented:
select ID, coalesce(level5_desc, level4_desc, level3_desc, level2_desc, level1_desc)
from ...