建议用统计表
Dim g As New sqlCrossTableBuilder("统计表1", "表A")g.HGroups.AddDef("产品")g.VGroups.AddDef("存放位置")g.Totals.addexp("数量", "iif(类型='出',-1*数量,数量)")g.HorizontalTotal = Trueg.Build()MainTable = Tables("统计表1")