试试
Dim g As New GroupTableBuilder("统计表", DataTables("tjb"))
g.Caption = "统计表"
g.Groups.AddDef("grade")
g.Groups.AddDef("class")
g.FromServer = True
g.SubTotal = True
g.Build()
Dim t As Table = Tables("统计表")
Dim dt As DataTable = t.DataTable
dt.DataCols.Add("民族个数",Gettype(Integer) )
dt.DataCols.Add("政治面貌种类数",Gettype(Integer) )
dt.DataCols.Add("合计",Gettype(Integer) ,"民族个数 * 政治面貌种类数")
For Each dr As DataRow In dt.DataRows
dr("民族个数") = dt.SQLGetValues("zb","grade='" & dr("grade") & "' And class='" & dr("class") & "'")
dr("治面貌种类数") = dt.SQLGetValues("zzmm","grade='" & dr("grade") & "' And class='" & dr("class") & "'")
Next