应该用过程实现,一个sql语句应该不能实现if..else的逻辑,继续关注
解决方案 »
- powerDesigner12.5 modify database 修改表结构会清空表
- SQL列索引无效问题 求助
- forms builder 的pre post问题!
- 存储进程中,如何将long型变量转换成字符型?
- 出现符号‘EXCEPTION’ 在需要下列条件之一
- 菜鸟菜问题,在线急等---clob
- sql*plus中可有直接看表的命令?
- 请问Oracle触发器里能执行Grant语句吗??
- oracle9i在solaris8系统上安装出错信息如内示!怎么解决!急!在线等待ing....
- 我想在我本机访问另一台远程机的ORACLE,另一台机子不在内网,只能通过互联网访问,怎么做?开放端口?
- 这个SQL语句怎么写,请高手帮忙,高分相谢
- 请推荐你认为最好的两本oracle教材及两本oracle参考资料,请不要多推荐
a.c= INPUT) a ,
(select a.* from table2 a ,table3 b where a.c= INPUT and a.a=b.a and a.b=b.b ) b
where a.a=b.a and a.b=b.b;
union
select a.* from table2 a ,table3 b where a.a=b.a and a.b=b.b and a.c= INPUT
select
decode(table1.A,null,table2.A,table1.A) as A,
decode(table1.A,null,table2.B,table1.B) as B,
decode(table1.A,null,table2.C,table1.C) as C,
decode(table1.A,null,table2.D,table1.D) as D
from table1,table2,table3,
( select A,
B,
decode(table1.A,NULL,'table2','table1') as flag
from table1,table3
where table3.A = table1.A(+)
and table3.B = table1.B(+)
) tempTable
where table1.A(+) = table3.A
and table1.B(+) = table3.B
and table2.A(+) = table3.A
and table2.B(+) = table3.B
and tempTable.A(+) = table3.A
and tempTable.B(+) = table3.B
and (
(tempTable.flag = 'table1' and table1.C = INPUT)
or
(tempTable.flag = 'table2' and table2.C = INPUT)
)
其中A、B为主KEY,NOT NULL。
谢谢大家
select
decode(table1.A,null,table2.A,table1.A) as A,
decode(table1.A,null,table2.B,table1.B) as B,
decode(table1.A,null,table2.C,table1.C) as C,
decode(table1.A,null,table2.D,table1.D) as D
from table1,table2,table3,
( select table3.A as A,
table3.B as B,
decode(table1.A,NULL,'table2','table1') as flag
from table1,table3
where table3.A = table1.A(+)
and table3.B = table1.B(+)
) tempTable
where table1.A(+) = table3.A
and table1.B(+) = table3.B
and table2.A(+) = table3.A
and table2.B(+) = table3.B
and tempTable.A(+) = table3.A
and tempTable.B(+) = table3.B
and (
(tempTable.flag = 'table1' and table1.C = INPUT)
or
(tempTable.flag = 'table2' and table2.C = INPUT)
)
union
select c.* from table2 c ,table3 d where c.a=d.a and c.b=d.b and c.c= INPUT
and not exists ( select 1 from table1 e where c.a=e.a and c.b=e.b )