程序为: with a as (SELECT O.ORDERKEY 出货单号, O.EXTERNORDERKEY 外部单号, OD.STATUS 状态码, os.description 状态名称, O.TYPE 出货单类型码, ot.description 出库单类型名称, o.notes 生产订单号, TO_CHAR(O.Requestedshipdate + 8 / 24, 'yyyy-mm-dd hh24:mi') as 请求出货日期, TO_CHAR(O.Actualshipdate + 8 / 24, 'yyyy-mm-dd hh24:mi') as 实际出货日期, OD.SKU 物料编码, s.descr 物料名称, to_char(lp.Lottable02) 供应商, OD.ORIGINALQTY 需求数量, Od.Ref02 产线,s.susr1 物料组 FROM ORDERS O inner JOIN /*(SELECT OD.ORDERKEY, OD.SKU, OD.Lottable02, SUM(OD.ORIGINALQTY) ORIGINALQTY, SUM(OD.OPENQTY) OPENQTY, SUM(OD.QTYALLOCATED) QTYALLOCATED, SUM(OD.QTYPICKED) QTYPICKED, SUM(OD.SHIPPEDQTY) SHIPPEDQTY FROM ORDERDETAIL OD where '' is null or OD.Lottable02 = '' GROUP BY OD.ORDERKEY, OD.SKU, OD.LOTTABLE02) ODD*/ ORDERDETAIL OD ON O.ORDERKEY = OD.ORDERKEY inner JOIN sku s ON od.sku = s.sku inner join codelkup ot on listname = 'ORDERTYPE'and ot.code =O.TYPE inner join orderstatussetup os on os.code = OD.STATUS left join (select Lottable02 ,orderkey,sum(qty) qty from pickdetail p inner join lotattribute l on p.lot=l.lot where p.status=9 group by orderkey,Lottable02) lp on o.orderkey=lp.orderkey ORDER BY O.Requestedshipdate, s.sku) select * from a where 1=1 ${if(len(wbdh)==0,"","and 外部单号 =('"+wbdh+"')")} |