例如:请求出货日期:2020年12月20日01:00 至 2020年12月21日10:00。时间跨度最长为一个月,应该怎么编写sql语句呢?设置日期控件还是文本控件比较好? 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.OPENQTY 未结数量, OD.QTYALLOCATED 分配量, OD.QTYPICKED 拣货量, OD.SHIPPEDQTY 发运量, lp.qty 发运量, 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 where 1=1 ${if(len(wbdh)==0,"","and O.EXTERNORDERKEY =('"+wbdh+"')")} ${if(len(wlbm)==0,"","and OD.SKU =('"+wlbm+"')")} ${if(len(scdd)==0,"","and o.notes =('"+scdd+"')")} ${if(len(ckdlx)==0,"","and ot.description =('"+ckdlx+"')")} ${if(len(qqchrq)==0,"","and TO_CHAR(O.Requestedshipdate + 8/24, 'yyyy-mm-dd hh24:mi') =('"+qqchrq+"')")} ORDER BY O.Requestedshipdate, s.sku |