此主题相关图片如下:微信截图_20211221130723.jpg

viewFile.asp?ID=163188[/upload]
为空的情况出现在,退货表 中有符合条件的数据,而 订单明细表 中无符合条件的数据(测试的数据:订单表、订单明细、退货表 各有一条数据)
Dim s3 As String = "2020年10月"
Dim filter As String="年月<= '"& s3 &"'"
Dim dtx As DataTable
Dim b As New sqlGroupTableBuilder("统计表2","订单明细")
b.C
Dim dt1 As fxDataSource
b.AddTable("订单明细","订单号","订单表","订单号") '添加统计表
b.Groups.AddDef("{订单表}.订单号") '添加客户列用于水平分组
b.Groups.AddDef("客户名称") '添加客户列用于水平分组
b.filter=filter
dt1 = b.BuildDataSource()
Dim b2 As New sqlGroupTableBuilder("统计表3","实收明细")
Dim dt2 As fxDataSource
b2.C
b2.Groups.AddDef("订单号") '根据产品ID分组
b2.filter=filter
dt2 = b2.BuildDataSource()
Dim b3 As New sqlGroupTableBuilder("统计表1","退货表")
Dim dt3 As fxDataSource
b3.C
b3.AddTable("退货表","订单号","订单表","订单号") '添加统计表
b3.Groups.AddDef("{订单表}.订单号") '根据产品名称分组
b3.filter=filter
dt3 = b3.BuildDataSource()
dt1.Combine("订单号",dt3,"订单号")
dt1.Combine("订单号",dt2,"订单号")
dt1.Show("统计表2") '显示统计结果,必须有这一句
[此贴子已经被作者于2021/12/21 22:08:14编辑过]