日期:2014-05-17 浏览次数:21537 次
select A.empno
      ,nvl(a.your_need, b.your_need) your_need
  from 
(
    select  empno
           ,cast(
                   (
                case when (select count(1) from user_tab_columns where table_name = 'EMP' and column_name = 'B') > 0 then empno
                    else null
                end
                ) 
            as varchar2(7)
            ) your_need
      from emp
)
   A,
    (
    select empno
           ,case when (select count(1) from user_tab_columns where table_name = 'EMP' and column_name = 'ENAME') > 0 then ENAME
                else null
           end your_need
      from emp
    ) B
where A.empno = B.empno