我想結合以下兩個查詢的輸出,所以他們在一行輸出任何幫助,你可以提供將非常感激。結合2查詢到1所以輸出是在單行
查詢1:
select FLT_NUM, SCH_DEP_DATE, sum (GROSS_WGT) as UWS_GROSS_WGT, sum (NETT_WGT) + SUM(BULK_WGT) as UWS_NETT_WGT
from
(select distinct
d.aln_code||d.flt_num as FLT_NUM,
trunc (d.sch_dep_date) flight_date,
d.brd_pnt,
d.off_pnt,
trunc(d.sch_dep_date) as Departure_date,
to_date(to_char(d.sch_dep_date, 'DD-MON-YYYY')||''||d.sch_dep_time_hrs||':'||d.sch_dep_time_min, 'DD-MON-YYYY HH24:MI') as SCH_DEP_DATE,
a.gross_wt as GROSS_WGT,
a.tare_wt as TARE_WGT,
a.nett_wt as NETT_WGT,
a.shpmnt_wt as BULK_WGT
from cfr_leg d, cfr_uws_hdr e, CFR_LEG_SEG f,CFR_UWS_LOAD_DTLS a
where d.fll_id = e.fll_id (+)
and d.fll_id = f.fll_id
and d.fll_id = a.fll_id
and d.flt_num = '0001'
and trunc (d.sch_dep_date) between '29-OCT-2016' and '29-OCT-2016'
and d.brd_pnt = 'LHR'
and f.opn_mode = 'J')
group by FLT_NUM, SCH_DEP_DATE
查詢2:
select
FLT_NUM,SCH_DEP_DATE, sum (BKD_WGT), sum (BKD_VOL)
from
(Select distinct
a.aln_code||a.flt_num as FLT_NUM,
trunc(a.dep_date)as SCH_DEP_DATE,
b.doc_prfx,
b.doc_num,
a.bkd_wt as BKD_WGT,
a.bkd_vol as BKD_VOL
from sbh_res_itnry a, sbh_car b, sbh_res c
where c.car_id = b.car_id (+)
and c.car_id = a.car_id
and a.aln_code = 'VS'
and a.flt_num = '0001'
and trunc (a.dep_date) = '29-OCT-2016'
AND a.cncl_ind = 'N'
and b.cncl_ind = 'N'
and c.enq_ind = 'N')
group by FLT_NUM,SCH_DEP_DATE
我一直在使用UNION ALL嘗試,但它在2行
VS0001 29-Oct-2016 21365.09 92.404281
VS0001 29-Oct-2016 22595 21907
我想看看輸出數據輸出如下:
FLT_NUM SCH_DEP_DATE UWS_GROSS_WGT UWS_NETT_WGT BKD WGT BKD_VOL
VS0001 29-Oct-2016 21365.09 92.404281 22595 21907
你有在查詢的列可能識別'UWS_GROSS_WGT'相到'UWS_NETT_WGT'?我正在尋找實際的字符串列來達到這個效果。如果是這樣,那麼你可以透視以獲得你的輸出。 –
是'a.gross_wt'是用於UWS_GROSS_WEIGHT –