Foxtable(狐表)用户栏目专家坐堂 → AggregateEnum用法


  共有557人关注过本帖树形打印复制链接

主题:AggregateEnum用法

帅哥,在线噢!
ycs5801
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:963 积分:6918 威望:0 精华:0 注册:2009/6/24 9:44:00
AggregateEnum用法  发帖心情 Post By:2024/1/24 12:35:00 [只看该作者]

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的行数。现在点击该按钮报错。

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107018 积分:544321 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/1/24 13:34:00 [只看该作者]

b.Totals.Addexp("bl2", "case when  次数=1 then 1 else 0 end", "船次") 

 回到顶部
帅哥,在线噢!
ycs5801
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:963 积分:6918 威望:0 精华:0 注册:2009/6/24 9:44:00
  发帖心情 Post By:2024/1/24 13:40:00 [只看该作者]

这个bl2从哪来的?没有这列啊

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107018 积分:544321 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/1/24 13:50:00 [只看该作者]

生成的统计表的列名

Totals.AddExp(Name, Expression, Caption, Aggregate)

Name:      字符型,指定列名
Expression:字符型,指定表达式

Caption:   字符型,指定列标题
Aggregate: AggregateEnum枚举型,用于指定统计类型,默认是求和。


 回到顶部