Dim b As New SQLGroupTableBuilder("统计表1", "产值调研数据")
b.Groups.AddDef("日期", DateGroupEnum.Year, "年")
b.Groups.AddDef("日期", "月")
b.Groups.AddDef("xz", "属地")
b.Totals.AddDef("产值月度同比增减额1", AggregateEnum.Max, "月产值增减额_最高值")
b.Totals.AddDef("产值月度同比增减额1", AggregateEnum.Average, "月产值增减额_平均值")
b.Totals.AddDef("产值月度同比增减额1", AggregateEnum.Min, "月产值增减额_最低值")
b.Totals.Adddef("产值月度同比增减额1", "月产值增减额_合计")
b.Totals.AddExp("增减_减少_额度", "iif(产值月度同比增减额1 < 0,产值月度同比增减额1,0)")
b.Totals.AddExp("增减_增加_额度", "iif(产值月度同比增减额1 > 0,产值月度同比增减额1,0)")
b.Totals.AddExp("增减_企业总数", "iif(isnull(产值月度同比增减额1),0,1 )")
b.Totals.AddExp("增减_持平_企业数", "iif(产值月度同比增减额1 = 0,1,0)")
b.Totals.AddExp("增减_减少_企业数", "iif(产值月度同比增减额1 < 0,1,0)")
b.Totals.AddExp("增减_增加_企业数", "iif(产值月度同比增减额1 > 0,1,0)")
b.Decimals = 0
b.VerticalTotal = True
b.Filter = "[日期]=# 2023-04-30 #"
'b.build()
Tables("查询与统计_table2").DataSource = b.BuildDataSource()
Dim r As Row
For i As Integer = 0 To Tables("查询与统计_table2").Rows.Count(True) - 1
r = Tables("查询与统计_table2").Rows(i, True)
If r.IsGroup Then
r("月产值增减额_平均值") = r("月产值增减额_合计") / r("增减_企业总数")
End If
Next
'Tables("查询与统计_table2").DataSource = b.BuildDataSource()
我的这段代码为报错,但为实现修正平均值(合计行)的目的,求高人指点!!!