以下是我对结果的 Oracle 选择查询,但我得到了我不需要的重复项。我觉得其他人很难找到,请尝试一下。
SELECT I.EID EID,
I.WT Title,
I.RID RID,
I.FORMNAME STAGENAME,
I.FORMS STATUS,
I.INPT Projects,
To_char(I.DVDD, 'DD/MM/YYYY') DVDD,
CASE
WHEN B.SID = 2
AND B.DID = 2 THEN Trunc(F.EVENTDATE) - I.DVDD
ELSE NULL
END DEVLAPSEDAYS,
To_char(I.MDD, 'DD/MM/YYYY') MDD,
CASE
WHEN B.SID = 2
AND B.DID = 2 THEN Trunc(F.EVENTDATE) - I.MDD
ELSE NULL
END MONITORLAPSEDAYS,
L.LDEID LEADEID
FROM table1 I,
table2 F,
table3 B,
table4 L
WHERE I.ACTIVEFLG = 1
AND I.LATESTFLG = 1
AND I.FORMSTATUS IN ( 1, 3 )
AND I.UNIQUEID = F.UNIQUEID
AND B.SID = 2
AND B.DID IN ( 2, 3 )
AND ( F.EVENTDATE > I.DVDD
OR F.EVENTDATE > I.MDD )
AND ( ( Trunc(F.EVENTDATE) - I.DVDD ) > 2
OR ( Trunc(F.EVENTDATE) - I.MDD ) > 2 )
AND F.LINKID = B.LINKID
AND I.FORMSTAGENAME IN ( 'Develop', 'Monitor' )