最近我遇到了一个非常奇怪的问题(Oracle 12c),LISTAGG适用于第一个别名列但不适用于第二个(两者几乎完全相同)抛出ORA-00904:“PARAMDESC”:无效的标识符。这是SQL:
SELECT s_sample.s_sampleid,
b.u_tarolotnumber,
p.productdesc,
s_sample.productid,
LISTAGG(wi.s_departmentid, '; ') WITHIN
GROUP(ORDER BY wi.s_departmentid) Department,
wi.workitemid,
s_sample.sampletypeid,
NVL((SELECT sa.aliasid
FROM sdialias sa
WHERE sa.sdcid = 'Workitem'
AND sa.keyid1 = wi.workitemid), wi.workitemdesc)workitemdesc,
NVL((SELECT sa.aliasid
FROM sdialias sa
WHERE sa.sdcid = 'ParamList'
AND sa.keyid1 = p.paramlistid), p.paramlistdesc) paramdesc
FROM s_sample
JOIN s_batch b ON s_sample.batchid = b.s_batchid
AND s_sample.classification = 'ReagentQuality'
JOIN s_product p ON s_sample.productid = p.s_productid
JOIN sdiworkitem sdi ON sdi.keyid1 = s_sample.s_sampleid
AND sdi.sdcid = 'Sample'
JOIN workitem wi ON wi.workitemid = sdi.workitemid
AND wi.workitemversionid = sdi.workitemversionid
JOIN sdiworkitemitem sdiwi ON wi.workitemid = sdiwi.workitemid
AND sdiwi.keyid1 = s_sample.s_sampleid
AND sdiwi.sdcid = 'Sample'
JOIN paramlist p ON p.paramlistid = sdiwi.itemkeyid1
AND p.paramlistversionid = sdiwi.itemkeyid2
AND p.variantid = sdiwi.itemkeyid3
WHERE s_sample.s_sampleid IN ('S100')
AND 1 = 1
GROUP BY s_sample.s_sampleid,
b. u_tarolotnumber,
p.productdesc,
s_sample.productid,
s_sample.sampletypeid,
wi.workitemid,
workitemdesc,
paramdesc;
很多谷歌搜索,但没有运气!任何帮助都将受到高度赞赏。
提前致谢 SUV