V FactTicket Fabri
V FactTicket Fabri
V FactTicket Fabri
SET QUOTED_IDENTIFIER ON
GO
[FactTicketKey]
-- ,[NaturalKey]
[TicketNumber]
,[amadeusBookingRlocID]
-- ,[bookingOriginalRlocID]
--,[dateOfIssue]
,[DateOfIssueKey]
,[DimPassengerTypeKey]
,[isRevenuePassenger]
,[isStudent]
,[DimTicketRAEventKey]
,[passengerLastName]
,[passengerFirstName]
,[provisionalFinalIndicator]
,[DomIntIndicator]
,[DimTicketStatusKey]
,[dimTourcodeKey]
,[DimTicketTransactionCodeKey]
,[DimAirportKey_TrueOrigin]
,[DimAirportKey_TrueDestination]
,[DimAirlineCarrierKey_ValidatingCarrier]
,[DimTicketTransactionTypeKey]
-- ,[isdeleted]
,[SourceSystemCode]
,[TicketSourceSystemPk]
,[Tkt_ORC_Amt]
,[Refunded_Tkt_ORC_Amt]
,[Tkt_Net_Acct_Fare_Amt]
,[Refunded_Tkt_Net_Acct_Fare_Amt]
,[Tkt_Published_Acct_Fare_Amt]
,[Refunded_Tkt_Published_Acct_Fare_Amt]
,[Tkt_Selling_Acct_Fare_Amt]
,[Refunded_Tkt_Selling_Acct_Fare_Amt]
,[Tkt_COAM_Commission_Acct_Amt]
,[Refunded_Tkt_COAM_Commission_Acct_Amt]
,[Tkt_SPAM_Commission_Acct_Amt]
,[Refunded_Tkt_SPAM_Commission_Acct_Amt]
,[Tkt_Fee_Acct_Amt]
,[Refunded_Tkt_Fee_Acct_Amt]
,[Tkt_Tax_Acct_Amt]
,[Refunded_Tkt_Tax_Acct_Amt]
,[Tkt_Fee_Count]
,[Refunded_Tkt_Fee_Count]
,[Tkt_Tax_Count]
,[Refunded_Tkt_Tax_Count]
,[Total_Ticket_Count]
,[Refunded_Total_Ticket_Count]
-- ,[RecordCreatedTimestamp]
,[RecordUpdatedTimestamp]
,coalesce ([RecordUpdatedTimestamp],[RecordcreatedTimestamp]) as
RecordUpdatedDate
,[DimTicketEMDOfficeKey]
, cA.customerAccountNumber
,pymnt.PaymentType
,pymnt.PaymentCode
left join (
select distinct t.Sourcesystempk , customerAccountNumber from [dbo].
[TicketEMDOrder] t
inner join (
select TKT_EMD_OrderHGNK , substring(tfop.customerAccountNumber, patindex('%
[^0]%',tfop.customerAccountNumber), 100) as customerAccountNumber
FROM [dbo].[TICKETEMDFORMOFPAYMENT] tfop
where tfop.currentrecordindicator='Y'
and tfop.isdeleted =0
and tfop.ordertype ='TKT'
and customerAccountNumber is not null) CustAcct on
CustAcct.TKT_EMD_OrderHGNK=t.hashguid
where
--dateofissue > '2020-01-01 00:00:00.000'
t.OrderType = 'TKT'
and t.currentrecordindicator = 'Y'
and t.isdeleted=0
) cA on cA.Sourcesystempk = A.TicketSourceSystemPK
left join (
select distinct t.Sourcesystempk , PaymentType, PaymentCode from [dbo].
[TicketEMDOrder] t
inner join (
select TKT_EMD_OrderHGNK , PaymentType, PaymentCode
FROM [dbo].[TICKETEMDFORMOFPAYMENT] tfop
where tfop.currentrecordindicator='Y'
and tfop.isdeleted =0
and tfop.ordertype ='TKT'
AND (paymentcode like 'GOV%' or paymentcode like 'GR%')) pType on
pType.TKT_EMD_OrderHGNK=t.hashguid
where
--dateofissue > '2020-01-01 00:00:00.000'
t.OrderType = 'TKT'
and t.currentrecordindicator = 'Y'
and t.isdeleted=0
) pymnt on pymnt.Sourcesystempk = A.TicketSourceSystemPK;
GO