我需要根据Schedule表中的STATION
在Avg Delay Departure表中显示'0'值。
这是Schedule表,
+---------+---------+----------+
| Station | On Time | Schedule |
+---------+---------+----------+
| AMQ | 174 | 202 |
| AMS | 21 | 27 |
| BDJ | 182 | 210 |
| BDO | 56 | 62 |
| BEJ | 59 | 62 |
| BIK | 74 | 93 |
| BKK | 81 | 87 |
| BKS | 73 | 87 |
| BMU | 60 | 60 |
| BOM | 2 | 7 |
| BPN | 413 | 452 |
+---------+---------+----------+
这是Avg Delay表,
+---------+---------------------+
| Station | Avg Delay Departure |
+---------+---------------------+
| AMQ | 53.21 |
| AMS | 49.5 |
| BDJ | 60.78 |
| BDO | 67.66 |
| BEJ | 46.33 |
| BIK | 47.53 |
| BKK | 55.5 |
| BKS | 67.56 |
| BOM | 45.2 |
| BPN | 53.81 |
+---------+---------------------+
注意Schedule表中的BMU
记录。它有60个时间表和60个准时,所以没有延迟。我想在平均延迟表中显示BMU
记录,Avg Delay Departure
列的值为'0'。我当前的查询不显示。
这是Avg Delay表的查询,
SELECT DEPAIRPORT AS STATION, to_number(to_char(trunc(sysdate) + avg(cast(ACTUAL_BLOCKOFF_LC as date) - cast(SCHEDULED_DEPDT_LC as date)), 'sssss'))/60 as DEPAVERAGE
FROM DBODSXML4OPS.XML4OPS
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 DEPAIRPORT
ORDER BY STATION ASC;