参考
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("第一列", Gettype(String), 16)
dtb.AddDef("总数量", Gettype(Integer))
dtb.AddDef("总批次", Gettype(Integer))
dtb.Build()
For Each nm As String In DataTables("表A").GetValues("第一列")
Dim dr As DataRow = DataTables("统计").AddNew()
dr("第一列") = nm
dr("总数量") = DataTables("表A").Compute("Sum(数量)","第一列 = '" & dr("第一列") & "'")
dr("总批次") = DataTables("表A").GetValues("第六列", "第一列 = '" & dr("第一列") & "'").Count
Next
MainTable= Tables("统计")
http://www.foxtable.com/help/topics/2394.htm