Dim b As New SQLGroupTableBuilder("统计表1", "操作表")
b.C
b.AddTable("操作表", "sureyid", "主表", "sureyid") '添加统计表
b.Groups.AddDef("cargo", "货物名称") '根据产品名称分组
b.Totals.AddDef("weightofcargo", "", "水尺总和") '对数量进行统计
'b.Totals.AddDef("bl") '对数量进行统计
b.Totals.Addexp("bl", "case when 次数=1 then bl else 0 end","提单总和" )
b.Totals.Addexp("bl", "case when 次数=1 then true else false end", "船次", AggregateEnum.count)
Dim filter As String
With e.Form.Controls("StartDate1")
If .Value IsNot Nothing Then
Filter = "日期 >= '" & .Value & "'"
End If
End With
With e.Form.Controls("EndDate1")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= '" & .Value & "'"
End If
End With
With e.Form.Controls("货物")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "[cargo]= '" & .Value & "'"
End If
End With
With e.Form.Controls("贸易类别")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "[impexp]= '" & .Value & "'"
End If
End With
With e.Form.Controls("来自国家")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "[country]= '" & .Value & "'"
End If
End With
With e.Form.Controls("申请方式")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "[type]= '" & .Value & "'"
End If
End With
With e.Form.Controls("船代")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "[company]= '" & .Value & "'"
End If
End With
'b.filter = "日期>='01/05/2023' and 日期<='08/09/2023' and [cargo] = '煤'"
If Filter > "" Then
b.filter = filter
Tables("主表_Table5").DataSource = b.BuildDataSource()
' Maintable = Tables("统计表1") '打开生成的统计表
'b.Build '生成统计表
Else
messagebox.Show("请填入选项再搜索")
End If
问题:黄色标记部分代码想实现增加一列统计列,列名为船次,统计出次数列等于1的行数。现在点击该按钮报错。