17,377
社区成员
发帖
与我相关
我的任务
分享
SQL>
SQL> create table test(id int, r1 varchar(10), r2 varchar(10), r3 varchar(10));
Table created
SQL> begin
2 insert into test values(1, '001',null,null);
3 insert into test values(2, '001','001001',null);
4 insert into test values(3, '001','001001','001001001');
5 insert into test values(4, '001','001001','001001002');
6 end;
7 /
PL/SQL procedure successfully completed
SQL> col id format a10 ;
SQL> select id, coalesce(r3,r2,r1) result from test;
ID RESULT
---------- ----------
1 001
2 001001
3 001001001
4 001001002
SQL> drop table test purge ;
Table dropped
SQL>