Dim t As Table = Tables("表A")
Dim filter = t.filter
Dim dic As new Dictionary(Of String ,Double)
For Each bj As String In t.DataTable.GetValues("班级", t.filter)
t.filter = iif(filter>"", filter & " And ", "") & "班级='" & bj & "' and 语文_分数 >= 60"
dic.add(bj & "平均", t.Aggregate(AggregateEnum.Average, 0, t.Cols("语文_分数").index, t.Rows.count-1, t.Cols("语文_分数").index))
dic.add(bj & "偏差", t.Aggregate(AggregateEnum.Std, 0, t.Cols("语文_分数").index, t.Rows.count-1, t.Cols("语文_分数").index))
Next
t.filter = filter
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "班级"
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
t.Subtotal()
Dim r As Row
For i As Integer = 0 To t.Rows.Count(True) - 1
r = t.Rows(i,True)
If r.IsGroup '如果是分组行
Dim f As String = "班级 = '" & r("班级") & "'"
Dim 语文及格数量 = t.Compute("Count(语文_判定)","语文_判定='P' and " & f)
Dim 班级人数 = t.Compute("Count(班级)",f)
Dim 语文优秀数量 = t.Compute("Count(语文_分数)","语文_分数> =90 and " & f)
Dim v As String = " 班级人数:" & 班级人数
v = v & " 语文及格数量(≥60):" & 语文及格数量
v = v & " 语文良好数量(≥80):" & t.Compute("Count(语文_分数)","语文_分数> =80 and " & f)
v = v & " 语文优秀数量(≥90):" & 语文优秀数量
v = v & " 语文及格率:" & 语文及格数量/班级人数
v = v & " 语文优秀率:" & 语文优秀数量/班级人数
v = v & " 语文最大值:" & t.Compute("Max(语文_分数)",f)
v = v & " 语文最小值:" & t.Compute("Min(语文_分数)",f)
v = v & " 语文及格分数平均值:" & dic(r("班级") & ("平均"))
v = v & " 语文及格分数标准偏差:" & dic(r("班级") & ("偏差"))
v = v & " 语文及格分数离散度:" & dic(r("班级") & ("偏差")) / dic(r("班级") & ("平均"))
r("班级") = "班级:" & r("班级") & v
End If
Next