我对2个视图进行了查询,当它结合时
查看X
A B C
2 3
查看Y
A B C
3 4
这是我在2个观点中的查询
select * from view X
UNION
select * from view Y;
我的结果:
A B C
2 3
3 4
我想要的结果(2覆盖视图Y @属性A中的空值):
A B C
2 3
2 3 4
我怎么能得到那个?
答案 0 :(得分:2)
试试这个
select nvl(A, lag(A) over (order by rownum)), B, C from (
select A, B, C from X
union
select A, B, C from Y
)
答案 1 :(得分:0)
这是oracle中的一个答案
select * from
(select x from tbl1
union
select x from tbl2) t1
,
(select y from tbl1
union
select y from tbl2) t2
,
(select z from tbl1
union
select z from tbl2) t3
where t1.x is not null
order by t1.x desc nulls first;