以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 增加分段统计列不显示 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=92800) |
-- 作者:刘林 -- 发布时间:2016/11/13 17:30:00 -- 增加分段统计列不显示 Dim g As New GroupTableBuilder("统计表1", DataTables("成绩")) \'\'\'\'Dim g As New GroupTableBuilder("统计表1", "成绩") Dim dt1 As Table = Tables("后台统计_table2") g.Groups.AddDef("考试名称") g.Groups.AddDef("单位名称") g.Groups.AddDef("年级代码") g.Groups.AddDef("班级") g.Totals.AddDef("姓名",AggregateEnum.Count,"参考人数") g.Totals.AddDef("语文_A",AggregateEnum.Average,"语文平均_A") g.Totals.AddDef("语文_B",AggregateEnum.Average,"语文平均_B") g.Totals.AddDef("数学_A",AggregateEnum.Average,"数学平均_A") g.Totals.AddDef("数学_B",AggregateEnum.Average,"数学平均_B") g.Totals.AddDef("英语_A",AggregateEnum.Average,"英语平均_A") g.Totals.AddDef("英语_B",AggregateEnum.Average,"英语平均_B") g.Totals.AddDef("政治_A",AggregateEnum.Average,"政治平均_A") g.Totals.AddDef("政治_B",AggregateEnum.Average,"政治平均_B") g.Totals.AddDef("历史_A",AggregateEnum.Average,"历史平均_A") g.Totals.AddDef("历史_B",AggregateEnum.Average,"历史平均_B") g.Totals.AddDef("物理_A",AggregateEnum.Average,"物理平均_A") g.Totals.AddDef("物理_B",AggregateEnum.Average,"物理平均_B") g.Totals.AddDef("化学_A",AggregateEnum.Average,"化学平均_A") g.Totals.AddDef("化学_B",AggregateEnum.Average,"化学平均_B") g.Totals.AddDef("生物_A",AggregateEnum.Average,"生物平均_A") g.Totals.AddDef("生物_B",AggregateEnum.Average,"生物平均_B") g.Totals.AddDef("地理_A",AggregateEnum.Average,"地理平均_A") g.Totals.AddDef("地理_B",AggregateEnum.Average,"地理平均_B") g.Totals.AddDef("体育",AggregateEnum.Average,"体育平均") g.Totals.AddDef("物理实验",AggregateEnum.Average,"物理实验") g.Totals.AddDef("化学实验",AggregateEnum.Average,"化学实验") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") g.Totals.AddDef("折总",AggregateEnum.Average,"折总平均") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") g.Totals.AddExp("300分以下","iif(总分 < 300,1,0)") g.FromServer = True dt1.DataSource = g.BuildDataSource() dt1.DataTable.DataCols.Add("班级排名",Gettype(Integer)) \'\'********"\'And [班级] = \'" & ary1(2) & And [单位名称] = \'" & ary1(1) & "\' Dim Arys1 As List(Of String()) = dt1.DataTable.GetValues("考试名称|单位名称|年级代码") For Each Ary1 As String() In Arys1 Dim drs As List(Of DataRow) = dt1.DataTable.Select("[考试名称] = \'" & ary1(0) & "\'and [年级代码] =\'" & ary1(2) & "\'", "折总平均 DESC") For m As Integer = 0 To drs.Count - 1 \'遍历所有行 If m > 0 AndAlso drs(m)("折总平均") = drs(m-1)("折总平均") Then \'如果总分和上一行相同 drs(m)("班级排名") = drs(m-1)("班级排名") \'则排名等于上一行 Else drs(m)("班级排名") = m + 1 \'设置排名 End If Next Next \'\'******** dt1.SetColVisibleWidth("考试名称|80|单位名称|160|年级代码|40|班级|30|参考人数|30|语文平均_A|40|语文平均_B|40|数学平均_A|30|数学平均_B|40|英语平均_A|40|英语平均_B|40|政治平均_A|40|政治平均_B|40|历史平均_A|40|历史平均_B|40|物理平均_A|40|物理平均_B|40|化学平均_A|40|化学平均_B|40|生物平均_A|40|生物平均_B|40|地理平均_A|40|地理平均_B|40|体育平均|40|物理实验|40|化学实验|40|总分平均|70|折总平均|70|班级排名|40|300分以下|20") Dim btn2 As WinForm.Button = e.Form.Controls("Button2") btn2.PerformClick() 请问想在分组统计表中继续增加总分分段统计,为什么不行,请指教,谢谢!
|
-- 作者:y2287958 -- 发布时间:2016/11/13 22:01:00 -- 要用sqlGroupTableBuilder |
-- 作者:有点色 -- 发布时间:2016/11/14 9:21:00 -- 只有后台统计,才可以用表达式
http://www.foxtable.com/webhelp/scr/1626.htm
|
-- 作者:有点蓝 -- 发布时间:2016/11/14 9:47:00 -- 如果想保留表达式列的统计,只能在统计完成后再用Compute计算总分分段统计 |
-- 作者:有点蓝 -- 发布时间:2016/11/14 10:03:00 -- ...... g.Totals.AddDef("折总",AggregateEnum.Average,"折总平均") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") \'g.Totals.AddExp("300分以下","iif(语文_A < 300,1,0)") g.FromServer = True dt1.DataSource = g.BuildDataSource() dt1.DataTable.DataCols.Add("班级排名",Gettype(Integer)) dt1.DataTable.DataCols.Add("300分以下",Gettype(Integer)) For Each dr As DataRow In dt1.DataTable.DataRows dr("300分以下") = DataTables("成绩").Compute("count(总分)","[考试名称] = \'" & dr("考试名称") & "\'and [年级代码] =\'" & dr("年级代码") & "\' and 单位名称 = \'" & dr("单位名称") & "\' and 班级=\'" & dr("班级") & "\' and 总分 < 300" ) Next ......
|
-- 作者:刘林 -- 发布时间:2016/11/14 13:14:00 -- 要不要加数据源 |
-- 作者:刘林 -- 发布时间:2016/11/14 13:18:00 -- Dim g As New sqlGroupTableBuilder("统计表1", "成绩") g.C Dim dt1 As Table = Tables("后台统计_table2") g.Groups.AddDef("考试名称") g.Groups.AddDef("单位名称") g.Groups.AddDef("年级代码") g.Groups.AddDef("班级") g.Totals.AddDef("姓名",AggregateEnum.Count,"参考人数") g.Totals.AddDef("语文_A",AggregateEnum.Average,"语文平均_A") g.Totals.AddDef("语文_B",AggregateEnum.Average,"语文平均_B") g.Totals.AddDef("数学_A",AggregateEnum.Average,"数学平均_A") g.Totals.AddDef("数学_B",AggregateEnum.Average,"数学平均_B") g.Totals.AddDef("英语_A",AggregateEnum.Average,"英语平均_A") g.Totals.AddDef("英语_B",AggregateEnum.Average,"英语平均_B") g.Totals.AddDef("政治_A",AggregateEnum.Average,"政治平均_A") g.Totals.AddDef("政治_B",AggregateEnum.Average,"政治平均_B") g.Totals.AddDef("历史_A",AggregateEnum.Average,"历史平均_A") g.Totals.AddDef("历史_B",AggregateEnum.Average,"历史平均_B") g.Totals.AddDef("物理_A",AggregateEnum.Average,"物理平均_A") g.Totals.AddDef("物理_B",AggregateEnum.Average,"物理平均_B") g.Totals.AddDef("化学_A",AggregateEnum.Average,"化学平均_A") g.Totals.AddDef("化学_B",AggregateEnum.Average,"化学平均_B") g.Totals.AddDef("生物_A",AggregateEnum.Average,"生物平均_A") g.Totals.AddDef("生物_B",AggregateEnum.Average,"生物平均_B") g.Totals.AddDef("地理_A",AggregateEnum.Average,"地理平均_A") g.Totals.AddDef("地理_B",AggregateEnum.Average,"地理平均_B") g.Totals.AddDef("体育",AggregateEnum.Average,"体育平均") g.Totals.AddDef("物理实验",AggregateEnum.Average,"物理实验") g.Totals.AddDef("化学实验",AggregateEnum.Average,"化学实验") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") g.Totals.AddDef("折总",AggregateEnum.Average,"折总平均") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") dt1.DataSource = g.BuildDataSource() g.Totals.AddDef("折总",AggregateEnum.Average,"折总平均") g.Totals.AddDef("总分",AggregateEnum.Average,"总分平均") g.FromServer = True dt1.DataSource = g.BuildDataSource() dt1.DataTable.DataCols.Add("班级排名",Gettype(Integer)) dt1.DataTable.DataCols.Add("300分以下",Gettype(Integer)) For Each dr As DataRow In dt1.DataTable.DataRows dr("300分以下") = DataTables("成绩").Compute("count(总分)","[考试名称] = \'" & dr("考试名称") & "\'and [年级代码] =\'" & dr("年级代码") & "\' and 单位名称 = \'" & dr("单位名称") & "\' and 班级=\'" & dr("班级") & "\' and 总分 < 300" ) Next \'\'********"\'And [班级] = \'" & ary1(2) & And [单位名称] = \'" & ary1(1) & "\' Dim Arys1 As List(Of String()) = dt1.DataTable.GetValues("考试名称|单位名称|年级代码") For Each Ary1 As String() In Arys1 Dim drs As List(Of DataRow) = dt1.DataTable.Select("[考试名称] = \'" & ary1(0) & "\'and [年级代码] =\'" & ary1(2) & "\'", "折总平均 DESC") For m As Integer = 0 To drs.Count - 1 \'遍历所有行 If m > 0 AndAlso drs(m)("折总平均") = drs(m-1)("折总平均") Then \'如果总分和上一行相同 drs(m)("班级排名") = drs(m-1)("班级排名") \'则排名等于上一行 Else drs(m)("班级排名") = m + 1 \'设置排名 End If Next Next \'\'******** dt1.SetColVisibleWidth("考试名称|80|单位名称|160|年级代码|40|班级|30|参考人数|30|语文平均_A|40|语文平均_B|40|数学平均_A|30|数学平均_B|40|英语平均_A|40|英语平均_B|40|政治平均_A|40|政治平均_B|40|历史平均_A|40|历史平均_B|40|物理平均_A|40|物理平均_B|40|化学平均_A|40|化学平均_B|40|生物平均_A|40|生物平均_B|40|地理平均_A|40|地理平均_B|40|体育平均|40|物理实验|40|化学实验|40|总分平均|70|折总平均|70|班级排名|40|300分以下|20") Dim btn2 As WinForm.Button = e.Form.Controls("Button2") btn2.PerformClick() 老师,我改成上面的结果是说总分,折总列无效,请指导
|
-- 作者:有点蓝 -- 发布时间:2016/11/14 14:21:00 -- sqlGroupTableBuilder不支持统计表达式列,只能重新用表达式进行统计,如 b.Totals.AddExp("折总","折总列的表达式") ,如果表达式嵌套了表达式的,还需要把所有的表达式都转换为数据列进行计算 如果想直接计算表达式列,只能用GroupTableBuilder,然后按照5楼的方式统计 |
-- 作者:刘林 -- 发布时间:2016/11/14 14:50:00 -- 老师按5楼方式统计,我试了下,400分以上均为0个,而实际不是这样 |
-- 作者:刘林 -- 发布时间:2016/11/14 14:57:00 -- 哦,这是要加载数据进行统计,老师,我是想不加载统计,请老师明示怎么办,我很需要一个后台统计 |