我正在使用以下腳本來獲取特定製造訂單的訂單歷史記錄;Oracle SQL,根據訂單歷史記錄計算下一訂單數量
select ds.status, ds.catnr, ds.part_no, ds.print_type, ds.nr_discs, ds.qty, ds.ship_date
from
(select 'Open Order' status, gb.catnr, gb.part_no, decode(gb.tec_criteria,'XX','SCREEN','OF','OFFSET','PI','OFFSET','MC','OFFSET') print_type, sp.nrunits nr_discs, sum(gb.or_menge_fd) qty, min(trunc(gb.shd_date)) ship_date
from gps_beweg gb, oes_customer oc, scm_packtyp sp
where gb.part_no = 'A0101628358-VV92-1900'
and gb.uebergabe_oes = '1'
and gb.pwerk_disc = 'W'
and gb.cunr = oc.cunr
and gb.packtyp = sp.packtyp
group by gb.cunr, oc.name, gb.part_no, sp.nrunits, gb.tec_criteria, gb.catnr, gb.prodtyp, gb.packtyp
UNION ALL
select unique 'Shipped Order' status,
null catnr, null part_no, null print_type, null nr_discs,
(select sum(ds1.planqty) from oes_delsegview ds1 where ds.ordnr = ds1.ordnr and ds.catnr = ds1.catnr and ds.prodtyp = ds1.prodtyp and ds.packtyp = ds1.packtyp) qty,
(select trunc(max(ds1.gps_planshpdate)) from oes_delsegview ds1 where ds.ordnr = ds1.ordnr and ds.catnr = ds1.catnr and ds.prodtyp = ds1.prodtyp and ds.packtyp = ds1.packtyp) ship_date
from part_description pd1, oes_delsegview ds
where pd1.part_no =
(select max(gb.part_no)
from gps_beweg gb
where gb.part_no = 'A0101628358-VV92-1900'
and gb.uebergabe_oes = '1'
and gb.pwerk_disc = 'W')
and pd1.catnr = ds.catnr
and pd1.prodtyp = ds.prodtyp
and pd1.packtyp = ds.packtyp
and ds.ord_o_status in ('7','9')
order by status, ship_date desc) ds
where rownum <=5
此腳本的結果看起來是這樣的......
我想用數據的數量和SHIP_DATE列來預測下一個數量和日期。我可以使用TREND函數在Excel中執行此操作。有沒有辦法在SQL中做到這一點?它是否符合REGR_SLOPE函數(我似乎無法讓我的頭瞭解它如何工作!?!)。
據我所知,在Oracle的SQL中沒有內容可以幫助你。儘管存在預測報告功能:https://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_commands_1052.htm#OLADM822。我從來沒有使用過,實際上也不知道如何調用它。您可以以某種方式使用它,或者使用Excel或任何提供該功能的工具在DBMS之外執行此操作。 –
感謝您的反饋,我將檢查預測功能(感謝您的鏈接)。我想我可能不得不恢復使用Excel功能。 – SMORF