以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 下面这段代码 执行起来 速度很慢 要等待 帮忙看一下 谢谢 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=188065) |
-- 作者:jswjyjf -- 发布时间:2023/8/30 12:17:00 -- 下面这段代码 执行起来 速度很慢 要等待 帮忙看一下 谢谢 下面这段代码 执行起来 速度很慢 要等待 帮忙看一下 谢谢 \'\'\'\' Dim exp As String = "1=1" Dim sq1 As String="selec 套数,入库, 出库,(isnull(套数,0)-isnull(出库,0)) as 结存, a.* from (SELEC * FROM 订单) a left join(" Dim sq2 As String="Selec 订单号, sum(入库) As 入库, sum(出库) As 出库 from (Selec 订单号, 数量 As 入库, 0 As 出库 from {成品入库单明细} where " & exp & "" \'Dim sq3 As String="union all Selec 产品编码,0, 盈亏数量 from {盘点单明细} where " & exp & "" \'Dim sq4 As String="union all Selec 产品编码,0, 数量 from {调拨单明细} where " & ck1 & "" \'Dim sq5 As String="union all Selec 产品编码,数量, 0 from {调拨单明细} where " & ck2 & "" Dim sq6 As String="union all Selec 订单号,0,数量 from {成品出库单明细} where " & exp & ") As d group by 订单号) As b on a.订单号 = b.订单号" Tables(e.form.Name & "_Table1").fill(sq1 &sq2 &sq6,"wjhansdata",True) Tables(e.form.Name & "_Table1").SetColVisibleWidth("订单号|98|日期|100|周别|180|订单PO号|180|成品料号|200|工令|180|套数|90|入库|90|出库|90|结存|128|") Tables(e.form.Name & "_Table1").DefaultRowHeight = 23 Tables(e.form.Name & "_Table1").DataTable.AllowResizeRow=False If Tables(e.form.Name & "_Table1").rows.count=0 Tables(e.form.Name & "_Table1").GrandTotal = False Else Tables(e.form.Name & "_Table1").Cols("出库").GrandTotal = True Tables(e.form.Name & "_Table1").Cols("入库").GrandTotal = True Tables(e.form.Name & "_Table1").Cols("结存").GrandTotal = True Tables(e.form.Name & "_Table1").Cols("套数").GrandTotal = True Tables(e.form.Name & "_Table1").GrandTotal = True \'显示合计模式 End If |
-- 作者:有点蓝 -- 发布时间:2023/8/30 13:40:00 -- 如果加载的行多肯定慢的。 sql可以优化一下 select 入库, 出库,(isnull(套数,0)-isnull(出库,0)) as 结存, a.* from 订单 as a left join (Select 订单号, sum(数量) As 入库 from {成品入库单明细} group by 订单号) as b on a.订单号 = b.订单号 left join (Select 订单号,sum(数量) As 出库 from {成品出库单明细} group by 订单号) as c on a.订单号 = c.订单号
|