0% found this document useful (0 votes)
24 views

Aws Scripts Dataload

The document is a SQL query that selects absence codes, descriptions, duty dates, employee numbers, names, and status from various tables including the ROSTER, ROSTERDT, vvCrewCodes, and vvcrewdb tables and inserts the results into the XX_ABSENCE_AIMS table in the FUSIONINTERFACE schema. It filters for specific absence codes and duty dates between 2024-01-01 and 2024-01-01.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Aws Scripts Dataload

The document is a SQL query that selects absence codes, descriptions, duty dates, employee numbers, names, and status from various tables including the ROSTER, ROSTERDT, vvCrewCodes, and vvcrewdb tables and inserts the results into the XX_ABSENCE_AIMS table in the FUSIONINTERFACE schema. It filters for specific absence codes and duty dates between 2024-01-01 and 2024-01-01.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

select VCC.CC as ABSENCE_CODE,VCC.CCDESC as ABSENCE_DESC,[dbo].

[fn_ToDate]
(R.DUTYDAY) DUTYDATE,r.ID as EPN
--,vv.CODE as PositionCode
--,CRCAT,cast(CRCAT as tinyint)
--,vvq.CWBASE
--,CRCAT,cast(CRCAT as tinyint)
--,cc.CREWCATIDX
--,vvq.AC
--,ac.IATACODE
,vc.NAME as 'NAME'
, stage_status = null
from ROSTER R
inner join ROSTERDT RD on r.LEG_DAY=rd.LEG_DAY
--inner join vvROSTERID RID on RID.ID=r.ID
--inner join LEGMAIN LM on LM.DAY=r.LEG_DAY and lm.DEP=r.LEG_DEP and
lm.FLT=r.LEG_FLT and lm.LEGCD=r.LEG_LEGCD
inner join vvCrewCodes VCC on vcc.ID=r.DUTYNO
inner join vvcrewdb vc on vc.ID=r.ID
inner join vvpositions vv on vv.RANK =r.pos

--left join CREWCATEG CC on cc.ID=r.ID and [dbo].[fn_ToDate] (R.DUTYDAY) not


between [dbo].[fn_ToDate] (cc.ACTIVEBEG) and [dbo].[fn_ToDate] (cc.ACTIVEEND)
CROSS APPLY
(
select top 1 vvq.* from vvqualifications vvq where vvq.ID = vc.ID and
vvq.PRIMARY_ = 0 and [dbo].[fn_ToDate] (ACTIVEND)>=[dbo].[fn_ToDate] (R.DUTYDAY)
--and vvq.AC in (5) --319 & 320
) as vvq

left outer join AIRCTYPE ac on ac.ACTYPE=vvq.AC

where VCC.CC in
('MD','SC','SOB','NQ','IDSL','CV19','IQ','COSL','DTHL','EML','HAJL','PATL','WEDL','
EXLV','SPTL','COML','NS','RF','NJ','OFLD')
--and month([dbo].[fn_ToDate] (R.DUTYDAY))=1 and year([dbo].[fn_ToDate]
(R.DUTYDAY))=2023
and [dbo].[fn_ToDate] (R.DUTYDAY) between '2024-01-01' and '2024-01-01'
--and vvq.CWBASE='RUH'
--and r.ID=41784
--and vv.CODE in ('PUR','CC')
group by
[dbo].[fn_ToDate] (R.DUTYDAY)
,r.ID ,
vc.NAME,
vv.CODE
,vvq.CWBASE,VCC.CC,VCC.ccdesc,vvq.AC,ac.IATACODE

--select * from AIRCTYPE


--select vvq.*,[dbo].[fn_ToDate] (ACTIVEND),[dbo].[fn_ToDate] (ACTIVBEG) from
vvqualifications vvq where id in(44955)

BEGIN
INSERT INTO FUSIONINTERFACE.XX_ABSENCE_AIMS
(
ABSENCE_CODE ,
ABSENCE_DESC ,
DUTYDATE ,
EPN ,
NAME ,
stage_status
)
VALUES
(
:ABSENCE_CODE ,
:ABSENCE_DESC ,
:DUTYDATE ,
:EPN ,
:NAME ,
:stage_status
);
commit;
END;

You might also like