我有一个奇怪的Oracle问题,其标识符在同一查询的另一个子查询中工作,并在主选择的FROM部分中定义。 select coalesce(typ...)
只返回一行和一个字段。这是查询的工作版本:
SELECT
v.id AS vid,
p.name AS pname,
v.name,
TO_CHAR(a.uploaddate,'YYYY-MM-DD HH24:MI:SS') AS scandate,
(SELECT COALESCE(sum(issuecount),0)
FROM foldercountcache fc, folder f
WHERE fc.folder_id = f.id
AND fc.projectversion_id = v.id AND f.name like '1 -%'
) as crit,
(SELECT COALESCE(typ,'No Issues') FROM
(SELECT ROWNUM AS r,cri,typ,n FROM
(SELECT f.name AS cri,i.issuetype AS typ, count(i.issuetype) as n
FROM issue i
LEFT JOIN folder f ON i.projectversion_id = f.projectversion_id AND i.folder_id = f.id
WHERE (i.projectversion_id = 15284846 AND f.name like '1%')
GROUP BY f.name,i.issuetype
ORDER BY cri, n DESC
)
) WHERE r=2
) AS top2
FROM projectversion v INNER JOIN project p ON p.id = v.project_id
INNER JOIN artifact a ON a.projectversion_id = v.id
WHERE a.uploaddate =
(SELECT max(uploaddate)
FROM artifact
WHERE projectversion_id = v.id AND status = 'PROCESS_COMPLETE'
)
ORDER BY p.name, v.name, a.uploaddate ;
我需要将号码15284846
替换为v.id
。但是,这样做,我收到了
ORA-00904 "V"."ID" invalid identifier
来自Oracle的错误。
请注意,在v.id
select COALESCE
使用没有问题
这里有什么问题?