-- 作者:susu312
-- 发布时间:2018/8/8 10:56:00
-- SQLGroupTableBuilder和 分组统计
SQLGroupTableBuilder这个可以设置只统计加载的数据么?
因为我的系统是分级别的,根据单位,如果统计数据库,那下级单位都可以统计上级的单位的了 ,这个不行?
Dim b As New SQLGroupTableBuilder("统计表1","person") \'Dim b As New GroupTableBuilder("统计表1","person") b.C b.Groups.Adddef("organName","单位") b.Totals.Adddef("cardID",AggregateEnum.Count,"人数") Dim nms() As String = {"sex"} For Each nm As String In nms \'利用表达式统计及格人数和优秀人数 b.Totals.Addexp( "性别_男","Case When " & nm & " = \'男\' Then 1 Else 0 End") b.Totals.Addexp( "性别_女","Case When " & nm & " = \'女\' Then 1 Else 0 End") Next b.VerticalTotal = True b.Build
For Each nm As String In nms \'对生成的统计表增加表达式列,计算及格率和优秀率 DataTables("统计表1").DataCols.Add( "性别_男占比",Gettype(Double), "性别_男/人数" ) Tables("统计表1").Cols("性别_男占比").Move(Tables("统计表1").Cols("性别_男").Index + 1) DataTables("统计表1").DataCols.Add( "性别_女占比",Gettype(Double), "性别_女/人数" ) Tables("统计表1").Cols("性别_女占比").Move(Tables("统计表1").Cols("性别_女").Index + 1) DataTables("统计表1").DataCols( "性别_男占比").SetFormat("0.00%") DataTables("统计表1").DataCols( "性别_女占比").SetFormat("0.00%") Next Tables("统计表1").Cols("单位").TextAlign = TextAlignEnum.Center Tables("统计表1").Cols("人数").TextAlign = TextAlignEnum.Center Tables("统计表1").Cols("性别_男").TextAlign = TextAlignEnum.Center Tables("统计表1").Cols("性别_女").TextAlign = TextAlignEnum.Center Tables("统计表1").Cols("性别_男占比").TextAlign = TextAlignEnum.Center Tables("统计表1").Cols("性别_女占比").TextAlign = TextAlignEnum.Center
MainTable = Tables("统计表1")
这个功能用分组统计做不出来吧?
|