FDL60 #zhusanjiao
--FDL60
SELECT CASE WHEN t.dep_date BETWEEN '2020-04-01' AND '2020-04-30' THEN '本期'
ELSE '同期' END 周期,
t.ex_dif 阶段,
nvl(t.air_code,'行业') 航司,
nvl(t.eline,'航线合计') 航线,
-- t.up_location || t.dis_location 航段,
-- t.flight_no 航班号,
-- p.all_area 流向,
sum(t.cap * trunc(1 / (dis_ord - up_ord)) * t.dist) ASK,
sum(t.ty * trunc(1 / (dis_ord - up_ord)) * t.dist) RPK,
sum(t.bkd) BKD,
sum(t.cap_fixed) CAP,
sum(t.ty_income_fixed * trunc(1 / (dis_ord - up_ord))) TYSR,
sum(t.pro_income_fixed) SR,
sum(t.bkd * t.price) QJ,
sum(ty_income_fixed * trunc(1 / (dis_ord - up_ord))) /
nullif(sum(cap * trunc(1 / (dis_ord - up_ord)) * dist), 0) 座收,
sum(pro_income_fixed) / nullif(sum(bkd * price), 0) 折扣,
sum(pro_income_fixed) / nullif(sum(bkd), 0) 票价,
sum(ty * trunc(1 / (dis_ord - up_ord)) * dist) / nullif(sum(cap * trunc(1 / (dis_ord - up_ord)) * dist), 0) 客座
FROM dcdb.v_tb_inport_detail60 t
-- LEFT JOIN dict.airport_new p ON t.dis_location = p.code3
WHERE (t.dep_date BETWEEN '2020-04-01' AND '2020-04-30'
OR t.dep_date BETWEEN '2019-04-01' AND '2019-04-30')
AND ex_dif IN ('-1', '2', '6', '14')
-- AND ex_date = to_char(sysdate, 'yyyy-mm-dd')
AND t.air_code IN ('ZH')
AND t.eline LIKE 'SZX%'
AND t.up_location IN ('SZX')
AND substr(t.flight_no, -1) BETWEEN '0' AND '9'
GROUP BY CASE WHEN t.dep_date BETWEEN '2020-04-01' AND '2020-04-30' THEN '本期'
ELSE '同期' END,
t.ex_dif,
ROLLUP ( t.air_code),
ROLLUP ( t.eline)
-- t.up_location || t.dis_location,
-- t.flight_no,
-- p.all_area