您可以创建嵌套表模式对象类型:
create type T_List1 as table of varchar2(100);
然后按如下方式构建您的查询:
select s.column_value as col1
, nvl(to_char(t.col2), '-') as col2
, nvl(col3, '-') as col3
from Table1 t
right join table(T_List1('A', 'B', 'C')) s
on (t.col1 = s.column_value)
例子:
-- sample of data from your question
with Table1(Col1, Col2, Col3) as(
select 'A', 34, 'X' from dual union all
select 'B', 43, 'L' from dual union all
select 'A', 36, 'L' from dual
) -- actual query
select s.column_value as col1
, nvl(to_char(t.col2), '-') as col2
, nvl(col3, '-') as col3
from Table1 t
right join table(T_List1('A', 'B', 'C')) s --< here list your values
on (t.col1 = s.column_value) -- as you would using `IN` clause
结果:
COL1 COL2 COL3
------------------------
A 36 L
A 34 X
B 43 L
C - -
SQLFiddle 演示