Error report:
ORA-00904: "RDD"."USED_END_DATE": invalid identifier
ORA-02063: preceding line from ADSWEBPROD
ORA-06512: at line 5
以下查询使我无效标识符错误。
DECLARE
TYPE demo_date_array_type IS TABLE OF dc_demo_dates.demo_date_id%TYPE;
updated_demo_dates demo_date_array_type;
BEGIN
SELECT ddd.demo_date_id
BULK COLLECT INTO
updated_demo_dates
FROM
dc_demo_dates ddd
JOIN
dc_demo_reservations ddr
ON
ddd.reservation_id = ddr.reservation_id
AND ddr.status NOT IN ('DENIED','CANCELLED')
AND ddr.demo_type <> 'Training'
AND ddr.environment IS NOT NULL
AND ddd.last_update_date > SYSTIMESTAMP - 1 -- updated in the last day
AND ddd.demo_start_date > SYSTIMESTAMP - 14 -- no older than 2 weeks
JOIN
(SELECT demo_date_id, used_start_date, used_end_date
FROM rps_by_demo_date
GROUP BY demo_date_id, used_start_date, used_end_date ) rdd
ON rdd.demo_date_id = ddd.demo_date_id
WHERE
ddd.demo_start_date != NVL(rdd.used_start_date, SYSTIMESTAMP) -- either start date
OR ddd.demo_end_date != NVL(rdd.used_end_date, SYSTIMESTAMP); -- or end date has changed
END;
如果我删除GROUP BY demo_date_id, used_start_date, used_end_date
or 如果我将最后OR
一个更改为 a AND
,则代码将成功执行(除非它没有给我所需的结果)
你知道会发生什么吗?谢谢
编辑:我将 group by 子句从子查询移到主查询中,并获得了我想要的结果。但我仍然不明白是什么导致了错误。