根据需要的时间及其他条件进行查询,用的是外部表,希望在窗口表中显示分组统计
代码如下:
s1 = " scph in (select scph from s_scph where jdrq between '" & d1 & "' and '" & d2 & "' and kfbh = '" & Trim(e.Form.Controls("Lkfbh").Text) & "')"
s3 = "Select (Select kfbh from sc_ddzb where scph = a.scph) 客户编号,(Select kfjc from sc_ddzb where scph = a.scph) 客户简称,scph 订单编号,xh 序号,cpbh 产品编号,cpmc 产品名称,lxbh 编号,xm 工序,xmsm 成本名称,je 预算单价,dhsl 订单数量,ysje 预算金额," _
& "(Select avg(dj) from sc_wfjgmx where ddbh = a.scph And xh = a.xh And lxbh = a.lxbh) As 实际单价,(Select sum(sl) from sc_wfjgmx where ddbh = a.scph And xh = a.xh And lxbh = a.lxbh) As 加工数量,((Select avg(dj) from sc_wfjgmx where ddbh = a.scph " _
& "And xh = a.xh And lxbh = a.lxbh)*(Select sum(sl) from sc_wfjgmx where ddbh = a.scph And xh = a.xh And lxbh = a.lxbh))As 加工金额 from sc_cpys a where lxbh In (2103,2106,5104,5107) and "
tb2.Fill(s3 & s1,"spData",True)
Dim b As New GroupTableBuilder("ddgx_hz",dtb2)
b.Groups.AddDef("工序","工序") '添加日期列用于分组,并用"年"代替原名称
'b.Groups.AddDef("工序","工序") '添加日期列用于分组,并用"月"代替原名称
b.Totals.AddDef("预算金额") '添加数量列用于统计
b.Totals.AddDef("加工金额") '添加金额列用于统计
b.Subtotal = False '生成汇总模式
b.Build '生成统计表
想实现用工序分组汇总,请教求解...
[此贴子已经被作者于2012-11-20 16:24:20编辑过]