栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

显示记录,即使它不存在

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

显示记录,即使它不存在

您可以创建一个嵌套表架构对象类型:

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 questionwith 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     -      -


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/382250.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号