簡體   English   中英

Oracle SQL-連接2個日期

[英]Oracle SQL - connecting 2 dates

我有以下代碼。 它有2個日期:

1。

(case 
    when not trunc(iv.dated) is null then trunc(iv.dated) else trunc(iv1.dated) 
end) date_stock_received

2。

trunc(dh.actshpdate) SHIP_DATE

有沒有一種方法可以加入日期,以便它們顯示在一個欄中?

select unique li.catnr, li.av_part_no, 
(select sum(pl.qty_onhand) from part_loc pl where li.av_part_no = pl.part_no) qty_onhand,
(case 
    when not trunc(iv.dated) is null then trunc(iv.dated) else trunc(iv1.dated) 
end) date_stock_received,
(case 
    when not sum(iv.quantity) is null then sum(iv.quantity) else sum(iv1.quantity) 
end) qty_received,
dp.delqty, od.ord_extordnr, trunc(dh.actshpdate) SHIP_DATE
from leos_item li
LEFT JOIN scm_packtyp sp
    ON li.packtyp = sp.packtyp
LEFT JOIN invtran_view_oes iv
    ON li.av_part_no = iv.part_no 
    and (iv.transaction = 'NREC' and iv.location_no = '        RETURNS    W')
LEFT JOIN invtran_view_oes iv1
    on li.av_part_no = iv1.part_no
    and (iv1.transaction = 'CORR+' and iv1.remark like 'STOCK FROM SP PALLET%')
LEFT JOIN oes_delsegview od
    ON od.catnr = li.catnr
    and od.prodtyp = li.prodtyp
    and od.packtyp = li.packtyp
LEFT JOIN oes_dpos dp
    ON od.ordnr = dp.ordnr
    and od.posnr = dp.posnr
    and od.segnr = dp.segnr
LEFT JOIN oes_dhead dh
    on dp.dheadnr = dh.dheadnr
    and dh.shpfromloc = 'W'
where li.cunr = '816900'
and substr(li.catnr,1,5) in ('RGMCD','RGJCD')
and li.item_type = 'FP'
and li.catnr = 'RGJCD221'
group by li.catnr, li.av_part_no, iv.dated, iv.quantity, iv1.dated, iv1.quantity, dp.delqty, 
dp.ordnr, dp.posnr, dp.segnr, od.ord_extordnr, dh.actshpdate
order by li.av_part_no

當前結果是...

在此處輸入圖片說明 我想看到的是

在此處輸入圖片說明 這可能嗎 ?

合並功能可能就是您想要的。

select trunc(coalesce(iv.dated, iv1.dated, dh.actshpdate)) theDateYouMightWant

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM