Dim bm As String = "统计表1"
Dim b As New SQLGroupTableBuilder(bm,"各班级学生健康登记表")
b.Groups.AddDef("班号")
b.Totals.AddExp("学生总数","1")
b.Totals.AddExp("其中_男生","iif(性别='男',1,0)")
b.Totals.AddExp("其中_女生","iif(性别='女',1,0)")
b.Totals.AddExp("体重正常_男生","iif(性别='男' and 体检结论_体重='正常',1,0)")
b.Totals.AddExp("体重正常_女生","iif(性别='女' and 体检结论_体重='正常',1,0)")
b.Totals.AddExp("身体偏重_男生","iif(性别='男' and 体检结论_体重='偏重',1,0)")
b.Totals.AddExp("身体偏重_女生","iif(性别='女' and 体检结论_体重='偏重',1,0)")
b.Totals.AddExp("体重偏轻_男生","iif(性别='男' and 体检结论_体重='偏轻',1,0)")
b.Totals.AddExp("体重偏轻_女生","iif(性别='女' and 体检结论_体重='偏轻',1,0)")
b.Totals.AddExp("视力正常_男生","iif(性别='男' and 体检结论_视力='正常',1,0)")
b.Totals.AddExp("视力正常_女生","iif(性别='女' and 体检结论_视力='正常',1,0)")
b.Filter = "班号 is not null and 学籍辅号 is not null"
b.Build
Tables(bm).AutoSizeCols
MainTable = Tables(bm)