Obsidian/Recognition/Work Related/프로젝트/스마트계류장/1.데이터베이스/주기장 기준 항공기 유무 확인 쿼리(GAM).md

44 lines
1.4 KiB
Markdown
Raw Normal View History

2024-03-08 09:25:42 +00:00
```sql
select nvl(standid, a.std_stand_no) as stand_no
, decode(standid, null, 'N', 'Y') as ac_stand_yn
, acregno as ac_reg_no
, acstype as ac_ty
, AC_GRAD AS AC_GRAD -- 항공기 등급(ICAO)
, PREDON_DT AS exp_stand_on_dt
, PREDOFF_DT AS exp_stand_off_dt
, ACTLON_DT AS actl_stand_on_dt
from (select ucm.FUN_PRE_ZERO_REMOVE(replace(a.stand_no, '00', '')) as std_stand_no
, decode(b.STAND_NO, null, 'N', 'Y') as cctv_yn
from ucm.SACP_STAND a, ucm.SACP_CCTVID_MAPPING b
where a.STAND_NO = b.STAND_NO (+)
and a.DSTRCT_TY in ( 'AF02003', 'AF02004', 'AF02007', 'AF02009' ) ) a,
(select standid
, acregno
, acstype
, icaoAcCat AS AC_GRAD -- 항공기 등급(ICAO)
, ucm.fun_utc_tm(predOnDate||predOnTime) AS PREDON_DT -- 예상 주기장 도착 시각
, ucm.fun_utc_tm(predOffDate||predOffTime) AS PREDOFF_DT -- 예상 주기장 출발 시각
, ucm.fun_utc_tm(actlOnDate||actlOnTime) AS ACTLON_DT -- 실제 주기장 도착 시각
from ueai.EAI_GRDACMVT_RCV a,
( select standid as standid_std, max(dateandtime) as if_dt_max
from ueai.EAI_GRDACMVT_RCV
where predonDate > to_char(sysdate -2, 'yyyymmdd')
and standid is not null
and ACTLONTIME is not null
and ACTLONTIMEOFNEXTSTD is null
group by standid ) b
where 1=1
and a.STANDID = b.standid_std
and a.DATEANDTIME = b.if_dt_max
and ACTLONTIME is not null
and ACTLOFFTIME is null ) b
where a.std_stand_no = b.standid(+)
order by stand_no
```