你在命令窗口执行下面的代码:
Dim dt1 As Date = #1/1/2013#
Dim dt2 As Date = #12/31/2013#
Dim dt As DataTable = DataTables("产品录入")
Dim filter As String = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "#"
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("姓名", Gettype(String), 32)
dtb.AddDef("完整_经手人1", Gettype(Integer))
dtb.AddDef("完整_经手人2", Gettype(Integer))
dtb.AddDef("水果_经手人1", Gettype(Integer))
dtb.AddDef("水果_经手人2", Gettype(Integer))
dtb.AddDef("零食_经手人1", Gettype(Integer))
dtb.AddDef("零食_经手人2", Gettype(Integer))
dtb.AddDef("时间_经手人1", Gettype(Integer))
dtb.AddDef("时间_经手人2", Gettype(Integer))
dtb.AddDef("个人利润_经手人1", Gettype(Integer))
dtb.AddDef("个人利润_经手人2", Gettype(Integer))
dtb.Build()
Dim lst1 As List(of String) = DataTables("产品录入").GetUniqueValues("","经手人一")
Dim lst2 As List(of String) = DataTables("产品录入").GetUniqueValues("","经手人二")
For Each nm As String In lst2
If Lst1.Contains(nm) = False Then
lst1.add(nm)
End If
Next
For Each nm As String In lst1
Dim r As Row = Tables("统计").AddNew()
r("姓名") = nm
r("完整_经手人1") = DataTables("产品录入").Compute("Count([_Identify])","经手人一 = '" & nm & "'")
r("完整_经手人2") = DataTables("产品录入").Compute("Count([_Identify])","经手人二 = '" & nm & "'")
r("零食_经手人1") = DataTables("产品录入").Compute("Count([_Identify])","经手人一 = '" & nm & "' And 类型 = '零食'")
r("零食_经手人2") = DataTables("产品录入").Compute("Count([_Identify])","经手人二 = '" & nm & "' And 类型 = '零食'")
r("水果_经手人1") = r("完整_经手人1") - r("零食_经手人1")
r("水果_经手人2") = r("完整_经手人2") - r("零食_经手人2")
r("个人利润_经手人1") = DataTables("产品录入").Compute("Sum(利润)","经手人一 = '" & nm & "'")
r("个人利润_经手人2") = DataTables("产品录入").Compute("Sum(利润)","经手人二 = '" & nm & "'")
Next