我在这里建立了一个相当复杂的查询。它的工作是选择尚未批准的文档的所有详细信息(这很有效),并向我返回文档参考列表和提交该文档的用户的名称。然后我想要做的是 LEFT JOIN 表到结果中,以便我获得所有尚未注册他们对这些文档的批准的用户(这是我在嵌套选择中所做的,即任何具有approvalstatus = ' Pending',我需要确定哪些记录需要添加。
SELECT substr(m.xreference,1,instr(m.xreference,'/')-1) Proj,
m.xreference,
m.xversion,
a1.assignedtoname,
a1.actiondate
FROM documentapprovers a1,
docmeta m,
(SELECT DISTINCT a2.documentid
FROM documentapprovers a2
WHERE a2.approvalstatus = 'Pending') penders
WHERE penders.documentid = a1.documentid
AND m.did = a1.documentid
AND a1.approverrole = 'Author'
AND a1.approvertitle = 'Author'
AND a1.actiondate <= SYSDATE - interval '3' month
ORDER BY proj ASC, a1.assignedtoname DESC, m.xreference asc
我尝试在嵌套上述查询时执行 LEFT JOIN,如下所示:
SELECT a3.assignedtoname, a4.*
FROM (SELECT substr(m.xreference,1,instr(m.xreference,'/')-1) Proj,
a1.documentid,
m.xreference,
m.xversion,
a1.assignedtoname,
a1.actiondate
FROM documentapprovers a1,
docmeta m,
(SELECT DISTINCT a2.documentid
FROM documentapprovers a2
WHERE a2.approvalstatus = 'Pending') penders
WHERE penders.documentid = a1.documentid
AND m.did = a1.documentid
AND a1.approverrole = 'Author'
AND a1.approvertitle = 'Author'
AND a1.actiondate <= SYSDATE - interval '3' month) a4
LEFT JOIN documentapprovers a3
ON a3.documentid = a4.documentid
但我收到命令未正确结束的错误。我一遍又一遍地重复它,对我来说它似乎完全终止了。任何人都可以帮忙吗?
请注意,它是 Oracle 的一个非常旧的版本,我认为是 8i。