-- 作者:mr725
-- 发布时间:2009/10/11 0:06:00
--
dim b As New SQLGroupTableBuilder("统计表1","jlj") b.Groups.AddDef("批次") b.Totals.AddDef("合格蛋数") b.build
with DataTables("统计表1") .DataCols.Add("淘汰", GetType(Integer)) .DataCols.Add("产蛋率", GetType(Double)) .DataCols.Add("入舍鸡产蛋率", GetType(Double)) End With
Tables("统计表1").Cols("淘汰").Move(1)
Maintable = Tables("统计表1") Tables("窗口1_Table1").DataSource = DataTables("统计表1") Tables("窗口1_Table1").Cols("淘汰").Move(1) For i as integer = 0 to Tables("统计表1").count -1 dim r as row = Tables("统计表1").Rows(i) dim n0 as integer = DataTables("jlj").Compute("Count(产蛋率)", "批次 = \'" & r("批次") & "\'") dim n as integer = DataTables("jlj").Compute("Count(入舍鸡产蛋率)", "批次 = \'" & r("批次") & "\'")
Dim Sum As Double = DataTables("jlj").Compute("Sum(产蛋率)", "批次 = \'" & r("批次") & "\'") Dim Sum1 As Double = DataTables("jlj").Compute("Sum(入舍鸡产蛋率)", "批次 = \'" & r("批次") & "\'") r("淘汰") = DataTables("jlj").Compute("Sum(淘汰)", "批次 = \'" & r("批次") & "\'") r("产蛋率") = Sum/n0 r("入舍鸡产蛋率") = Sum1/n \'这是简单算术平均数,加权平均数公式自己搞定吧。 Next
结果: 此主题相关图片如下:未命名1.jpg
但不知为何? 第二次执行时,会提示错误,说:不存在产蛋率和入舍产蛋率两列??? 郁闷啊~ 为何?=》Tables("窗口1_Table1")所在窗口要是关闭后重新打开就不会提示了~ ?
[此贴子已经被作者于2009-10-11 0:28:52编辑过]
|