我收到错误ORA-00904:" S"。" FLIGHTLEGREF":此标识符无效
JOIN STAT_1 S ON D.FLIGHTLEGREF = S.FLIGHTLEGREF
这是我的查询
WITH STAT_1 AS (SELECT DEPAIRPORT AS STATION
FROM DBODSXML4OPS.XML4OPS
WHERE ACTUAL_BLOCKOFF_LC IS NOT NULL AND SERVICETYPE IN ('J','G') AND STATUS IN ('Scheduled') AND TO_CHAR(SCHEDULED_DEPDT_LC, 'yyyy-mm-dd') BETWEEN '2018-04-14' AND '2018-05-14'
ORDER BY STATION ASC)
SELECT S.STAT_1 AS STATION, COALESCE((SELECT to_number(to_char(trunc(sysdate) + avg(cast(ACTUAL_BLOCKOFF_LC as date) - cast(SCHEDULED_DEPDT_LC as date)), 'sssss'))/60
FROM DBODSXML4OPS.XML4OPS
WHERE (ACTUAL_BLOCKOFF_LC - SCHEDULED_DEPDT_LC)*24*60 > '+000000015 00:00:00.000000000'), 0) as DEPAVERAGE
FROM DBODSXML4OPS.XML4OPS D
JOIN STAT_1 S ON D.FLIGHTLEGREF = S.FLIGHTLEGREF
WHERE ACTUAL_BLOCKOFF_LC IS NOT NULL AND SERVICETYPE IN ('J','G') AND --(ACTUAL_BLOCKOFF_LC - SCHEDULED_DEPDT_LC)*24*60 > '+000000015 00:00:00.000000000' AND
STATUS IN ('Scheduled') AND TO_CHAR(SCHEDULED_DEPDT_LC, 'yyyy-mm-dd') BETWEEN '2018-04-14' AND '2018-05-14'
GROUP BY S.STAT_1
ORDER BY STATION ASC;
有人有想法吗?
答案 0 :(得分:0)
您创建的STAT_1
表只包含一列 - STATION
,您可以执行其查询并查看。
因此,您需要在其查询中添加条件列:
,FLIGHTLEGREF
并将S.STAT_1
替换为STAT_1.STATION
中可用列的STAT_1
。
WITH STAT_1 AS (SELECT DEPAIRPORT AS STATION, FLIGHTLEGREF
FROM DBODSXML4OPS.XML4OPS
WHERE ACTUAL_BLOCKOFF_LC IS NOT NULL AND SERVICETYPE IN ('J','G') AND STATUS IN ('Scheduled') AND TO_CHAR(SCHEDULED_DEPDT_LC, 'yyyy-mm-dd') BETWEEN '2018-04-14' AND '2018-05-14'
ORDER BY STATION ASC)
SELECT STAT_1.STATION, COALESCE((SELECT to_number(to_char(trunc(sysdate) + avg(cast(ACTUAL_BLOCKOFF_LC as date) - cast(SCHEDULED_DEPDT_LC as date)), 'sssss'))/60
FROM DBODSXML4OPS.XML4OPS
WHERE (ACTUAL_BLOCKOFF_LC - SCHEDULED_DEPDT_LC)*24*60 > '+000000015 00:00:00.000000000'), 0) as DEPAVERAGE
FROM DBODSXML4OPS.XML4OPS D
JOIN STAT_1 ON D.FLIGHTLEGREF = STAT_1.FLIGHTLEGREF
WHERE ACTUAL_BLOCKOFF_LC IS NOT NULL AND SERVICETYPE IN ('J','G') AND --(ACTUAL_BLOCKOFF_LC - SCHEDULED_DEPDT_LC)*24*60 > '+000000015 00:00:00.000000000' AND
STATUS IN ('Scheduled') AND TO_CHAR(SCHEDULED_DEPDT_LC, 'yyyy-mm-dd') BETWEEN '2018-04-14' AND '2018-05-14'
GROUP BY STAT_1.STATION
ORDER BY STAT_1.STATION ASC;