Встретил ")." ожидал одного из "как" в терадате
Я получаю вышеупомянутую ошибку при выполнении запроса к Teradata Studio express
select
Union16.Item as Item,
Union16.Description as Description,
Union16.Nbr_Trans as Nbr_Trans,
Union16.Unit_price as Unit_price,
Union16.Amount as Amount,
MIN(Union16.Amount) as Total_Amount_
from (select AL1.ticket_document_number as ticket_document_number,
AL1.transaction_code as transaction_code,
AL1.void_status as void_status,
AL1.transaction_date as transaction_date,
AL1.pnr_record_locator as pnr_record_locator,
AL1.settlement_base_fare_amt as settlement_base_fare_amt,
AL1.settlement_total_tax_amt as settlement_total_tax_amt,
AL1.Multiplier as Multiplier,
(AL1.Multiplier * 2) as Service_Incentive_Fee,
(AL1.Multiplier * 2) as Transaction_Fee,
(case when AL1.TRANSACTION_CODE = 'ET' and AL1.VOID_STATUS = 'N' then 1
when AL1.TRANSACTION_CODE = 'RF' and AL1.VOID_STATUS = 'N' then -1
else 0
end) as NetTrans,
0 as Comm_Amount,
SUM(1) as Total_Trans,
AL1.period_end_date as period_end_date,
SUM(NetTrans * 2) as Service_Fee_due,
AL1.airline_code as airline_code,
1 as Item,
(('Supplier Link Service Incentive Fee @ $' || '2') || '/Tix') as Description,
2 as Unit_price,
SUM(NetTrans * 2) as Amount,
SUM(NetTrans * 2) as Transaction_Fee_due,
SUM((NetTrans * 2) + (NetTrans * 2)) as Total_Due,
SUM(1) as Total_Total_Trans_,
SUM(NetTrans * 2) as Total_Service_Fee_due_,
SUM(NetTrans * 2) as Total_Transaction_Fee_due_,
SUM((NetTrans * 2) + (NetTrans* 2)) as Total_Total_Due_,
SUM(NetTrans) as Net_Trans,
SUM(NetTrans) as Total_Net_Trans_,
SUM(NetTrans) as Nbr_Trans
from (SELECT LAST_DAY(AL1.period_end_date) AS PEDHEADER,
AL1.TICKET_DOCUMENT_NUMBER as TICKET_DOCUMENT_NUMBER ,
(case when AL1.TRANSACTION_CODE = 'ET' and AL1.VOID_STATUS = 'N' then 1
when AL1.TRANSACTION_CODE = 'RF' and AL1.VOID_STATUS = 'N' then -1
else 0
end) as NetTrans,
(case
when AL1.VOID_STATUS = 'V' then 0
when AL1.VOID_STATUS <> 'V' and AL1.TRANSACTION_CODE in ('AT','ET') then 1
when AL1.VOID_STATUS <> 'V' and AL1.TRANSACTION_CODE = 'RF' then -1
when AL1.VOID_STATUS <> 'V' and AL1.TRANSACTION_CODE not in ('AT','ET','RF') then 0
end
) as Multiplier,
AL1.TRANSACTION_CODE as TRANSACTION_CODE ,
AL1.VOID_STATUS as VOID_STATUS,
cast(AL1.TRANSACTION_DATE as date) as TRANSACTION_DATE ,
AL1.PNR_RECORD_LOCATOR as PNR_RECORD_LOCATOR ,
AL1.SETTLEMENT_BASE_FARE_AMT as SETTLEMENT_BASE_FARE_AMT ,
AL1.SETTLEMENT_TOTAL_TAX_AMT as SETTLEMENT_TOTAL_TAX_AMT,
cast(AL1.PERIOD_END_DATE as date) as PERIOD_END_DATE ,
AL1.AIRLINE_CODE as AIRLINE_CODE,
airline_name as airline_name ,
SUM (1 ) as Total_records,
0 as Total_comm_due,
SUM ((Multiplier * 2) ) as total_serv_inc_fee,
SUM ((Multiplier * 2) ) as total_trans_fee_due,
((0 + SUM((Multiplier * 2) )) + SUM((Multiplier * 2) )) as Total_amt_due,
0 as Comm_Amount,
(Multiplier * 2) as Service_Incentive_Fee,
(Multiplier * 2) as Transaction_Fee,
1 as cntr
FROM ODS_VIEWS.BOP_ARC_SETTLEMENT AL1
LEFT OUTER JOIN
(select tabC.refvalcode, tabC.acct_cd, tabC.airline_name, tabC.refvaltm
from (select ref1.refvalcode , max(case when ref1.refvalattribcode='numericCode' then ref1.refvalvalue else null end) as acct_cd,
max(case when ref1.refvalattribcode='Codedescription' then ref1.refvalvalue else null end) as airline_name,
tabA.refvaltm
from bial.refvalue ref1, (select refvalcode, refvalvalue as airline_name, max(refvalueid) as "refvaltm"
from bial.refvalue
where refvalcodesetcode='Carrier'
and refvalattribcode='Codedescription'
group by refvalcode, refvalvalue) tabA
where tabA.refvalcode = ref1.refvalcode
and ref1.refvalcodesetcode='Carrier'
group by ref1.refvalcode, tabA.refvaltm ) tabC
,
(select tabB.acct_cd, max(tabB.refvaltm) as "refvaltm"
from (select ref1.refvalcode , max(case when ref1.refvalattribcode='numericCode' then ref1.refvalvalue else null end) as acct_cd,
max(case when ref1.refvalattribcode='Codedescription' then ref1.refvalvalue else null end) as airline_name,tabA.refvaltm
from bial.refvalue ref1, (select refvalcode, refvalvalue as airline_name, max(refvalueid) as "refvaltm"
from bial.refvalue
where refvalcodesetcode='Carrier'
and refvalattribcode='Codedescription'
group by refvalcode, refvalvalue) tabA
where tabA.refvalcode = ref1.refvalcode
and ref1.refvalcodesetcode='Carrier'
group by ref1.refvalcode, tabA.refvaltm ) tabB
group by tabB.acct_cd
) tabD
where tabC.refvaltm = tabD.refvaltm
and tabC.acct_cd = tabD.acct_cd
) AIRDET
ON AL1.AIRLINE_CODE = AIRDET.acct_cd
WHERE cast(AL1.PERIOD_END_DATE as date) BETWEEN 01-01-2015 AND 31-01-2015
AND AL1.FILE_TYPE='AM'
AND AL1.SUPPLIER_LINK_INDICATOR='D'
AND AIRLINE_NAME = 'Alaska Airlines'
AND AL1.oltp_deleted_timestamp IS NULL
group by
AL1.period_end_date ,
AL1.TICKET_DOCUMENT_NUMBER,
NetTrans ,
Multiplier ,
AL1.TRANSACTION_CODE,
AL1.VOID_STATUS,
AL1.TRANSACTION_DATE,
AL1.PNR_RECORD_LOCATOR,
AL1.SETTLEMENT_BASE_FARE_AMT,
AL1.SETTLEMENT_TOTAL_TAX_AMT,
AL1.AIRLINE_CODE,
airline_name,
Total_comm_due,
Comm_Amount,
Service_Incentive_Fee,
Transaction_Fee,
cntr,
AL1.oltp_deleted_timestamp,
AL1.SUPPLIER_LINK_INDICATOR,
AL1.FILE_TYPE,
AL1.AIRLINE_CODE
)
) Union16
group by
Union16.Item,
Union16.Description,
Union16.Nbr_Trans,
Union16.Unit_price,
Union16.Amount
order by
Item asc,
Description asc;
1 ответ
Просто вы внимательно посмотрите на редактор запросов. Вы заметите, что Teradata Studio помечает позицию ошибки.
Перед производным столом отсутствует псевдоним ) Union16