嗨好人请查看下面的代码在db2中运行但在oracle中失败。
select * from
(select distinct e.time_stamp,e.applicationid, e.processname,
e.stage, e.initiatingsource, e.status, e.start_time, i.consultant,
g.cifnumber, g.applicantfirstname, g.applicantlastname,
case when e.branch is not null
then e.branch
else case when g.branch is not null
then g.branch
else i.branch
end
end as branch
from (select c.time_stamp, b.applicationid, b.processname,
b.stage, b.branch, b.initiatingsource,
case when d.status is null
then c.status
else d.status
end as status,
c.time_stamp as START_TIME,
case when d.time_stamp is not null
then d.time_stamp
else current_timestamp
ens as END_TIME
from (select distinct f.applicationid, f.branch, f.initiatingsource, f.processname,
case when f.stage in ('START''END')
then 'APPLICATION'
else f.stage, f.stagecounter
from processmetric f) b
left join processmetric c on b.applicationid = c.applicationid and b.processname = c.processname and (b.stage = c.stage or (b.stage = 'APPLICATION' and c.stage = 'START')) and b.stagecounter = c.stagecounter and c.phase = 'START'
left join processmetric d on b.applicationid = d.applicationid and b.processname = d.processname and (b.stage = d.stage or (b.stage = 'APPLICATION' and d.stage = 'END')) and b.stagecounter = d.stagecounter and d.phase ='END')e
left join applicationcustomerdata g on g.applicationid = e.applicationid
and g.time_stamp in (select max(x.time_stamp)
from applicationcustomerdata x
where x.applicationid = g.applicationid
)
left join applicationdata i on i.applicationid = e.applicationid
and i.time_stamp in (select max(z.time_stamp)
from applicationdata z
where z.applicationid = i.applicationid
)
order by e.start_time
) a
where a.start_time is not null and a.stage not in ('APPLICATION') and a.status not in ('COMPLETE' , 'COMPLETED' , 'CANCEL', 'FRAUD' , 'DECLINE') and a.stage = 'VERIFICATION';
答案 0 :(得分:0)
Oracle不允许使用子查询进行外连接。以下2个连接是有问题的:
printf()
您需要重写语句(如果您需要在一个SQL中使用所有这些)或者通过数据编写一些PL / SQL循环。