Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:AggregateEnum用法

1楼
ycs5801 发表于: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楼
有点蓝 发表于:2024/1/24 13:34:00
b.Totals.Addexp("bl2", "case when  次数=1 then 1 else 0 end", "船次") 
3楼
ycs5801 发表于:2024/1/24 13:40:00
这个bl2从哪来的?没有这列啊
4楼
有点蓝 发表于:2024/1/24 13:50:00
生成的统计表的列名

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

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

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

共4 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03125 s, 2 queries.