以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- AggregateEnum用法 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=190220) |
-- 作者:ycs5801 -- 发布时间:2024/1/24 12:35:00 -- AggregateEnum用法 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的行数。现在点击该按钮报错。
|
-- 作者:有点蓝 -- 发布时间:2024/1/24 13:34:00 -- b.Totals.Addexp("bl2", "case when 次数=1 then 1 else 0 end", "船次") |
-- 作者:ycs5801 -- 发布时间:2024/1/24 13:40:00 -- 这个bl2从哪来的?没有这列啊 |
-- 作者:有点蓝 -- 发布时间:2024/1/24 13:50:00 -- 生成的统计表的列名 Totals.AddExp(Name, Expression, Caption, Aggregate) Name: 字符型,指定列名 |