以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]如何把所有科目都缺考的学生排除在统计数据外?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=42987)

--  作者:方丈
--  发布时间:2013/11/27 15:52:00
--  [求助]如何把所有科目都缺考的学生排除在统计数据外?

在计算总分的表达式中:IsNull([语文],0) + IsNull([数学],0) + IsNull([英语],0)

这样三科都缺考的学生总分会成为“0分”,统计最低分的时候也会把这个缺考的学生统计为最低分

请教:如何把所有科目都缺考的学生排除在统计数据外?


--  作者:Bin
--  发布时间:2013/11/27 15:53:00
--  
http://www.foxtable.com/help/topics/2472.htm
--  作者:方丈
--  发布时间:2013/11/27 15:57:00
--  
不明白,需要再增加一个表达式列?能直接用代码吗?我是点击“分数分布表”后,直接统计成绩库中学生成绩的各科最高分、最低分、平均分、分数阶
[此贴子已经被作者于2013-11-27 16:00:01编辑过]

--  作者:Bin
--  发布时间:2013/11/27 15:58:00
--  
使用代码的话就不需要任何表达式了.  直接写统计条件即可    http://www.foxtable.com/help/topics/0393.htm
--  作者:方丈
--  发布时间:2013/11/27 16:03:00
--  

总分列用的是表达式,统计代码是写在  分数段统计_DataColChanged

 

 

Dim dr As DataRow = e.DataRow

Dim dt As DataTable =DataTables("学生成绩库")

If e.DataCol.Name = "科目" And e.DataRow.IsNull("科目") = False Then

    e.DataRow("参考人数") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 0 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("最高分") = Math.Round(dt.Compute("max(" & dr("科目") & ")","[期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" ),1)

    e.DataRow("最低分") = Math.Round(dt.Compute("min(" & dr("科目") & ")","[期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" ),1)

    e.DataRow("平均分") = Math.Round(dt.Compute("Avg(" & dr("科目") & ")","[期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" ),1)

    e.DataRow("T") = dt.Compute("Count(学生姓名)", dr("科目") & " Is Null  And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("S") = dt.Compute("Count(学生姓名)", dr("科目") & " = 0 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("R") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 1 And " & dr("科目") & " < 10 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("Q") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 10 And " & dr("科目") & " < 20 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("P") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 20 And " & dr("科目") & " < 30 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("O") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 30 And " & dr("科目") & " < 36 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("N") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 36 And " & dr("科目") & " < 40 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("M") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 40 And " & dr("科目") & " < 48 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("L") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 48 And " & dr("科目") & " < 50 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("K") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 50 And " & dr("科目") & " < 60 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("J") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 60 And " & dr("科目") & " < 70 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("I") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 70 And " & dr("科目") & " < 72 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("H") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 72 And " & dr("科目") & " < 80 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("G") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 80 And " & dr("科目") & " < 90 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("F") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 90 And " & dr("科目") & " < 100 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("E") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 100 And " & dr("科目") & " < 110 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("D") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 110 And " & dr("科目") & " < 120 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("C") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 120 And " & dr("科目") & " < 130 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("B") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 130 And " & dr("科目") & " < 140 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

    e.DataRow("A") = dt.Compute("Count(学生姓名)", dr("科目") & " >= 140 And [期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\'" )

   End If


--  作者:Bin
--  发布时间:2013/11/27 16:04:00
--  
用表达式就参考2楼,用代码就参考4楼.
--  作者:狐狸爸爸
--  发布时间:2013/11/27 16:16:00
--  

加上条件不就行啦:

 

 e.DataRow("最低分") = Math.Round(dt.Compute("min(" & dr("科目") & ")","[期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\' And “ & dr("科目") & ”> 0" ),1)

 

 

e.DataRow("最低分") = Math.Round(dt.Compute("min(" & dr("科目") & ")","[期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\' And  总分 > 0" ),1)

[此贴子已经被作者于2013-11-27 16:18:25编辑过]

--  作者:方丈
--  发布时间:2013/11/27 16:47:00
--  
谢狐爸,可以用了!但如果钻牛角尖的话:一个学生各科都考0分,这个学生要统计,另一个学生各科都缺考(成绩为空),这个学生不用统计,这样的话,上面的条件就不严密了
--  作者:Bin
--  发布时间:2013/11/27 16:52:00
--  
这不就是多加点判断是吗? 要学会据举一反三,08年注册这么久了.  多一个判断就不会了,又要问一次.这不科学呀.

空值使用   is null



--  作者:Bin
--  发布时间:2013/11/27 16:58:00
--  
e.DataRow("最低分") = Math.Round(dt.Compute("min(" & dr("科目") & ")","[期数] = \'" & e.DataRow("期数") & "\'And [班级] = \'" & e.DataRow("班级") & "\' And 语文 is not null and 数学 is not null and 英语 is not null),1)
[此贴子已经被作者于2013-11-27 17:02:20编辑过]