我正在使用以下脚本来获取特定制造订单的订单历史记录;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