以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何在父表列中有条件统计子表列  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=41561)

--  作者:chsh2004
--  发布时间:2013/10/22 15:44:00
--  如何在父表列中有条件统计子表列
父表:存款表 
子表:社员消费明细
关联:存款编号

目的:统计今天以前的消费金额;
计算方法:条件:配送日期>= 今天   统计之和:“金额”列
将存款表的“已消费金额”列 = “金额”列的统计之和
如何写啊!


Dim dt As DataTable = DataTables("存款表.社员消费明细")
Dim Total As Integer
Dim Customers As List(Of String)
Customers = dt.GetValues("数量")
For Each Customer As String In Customers
    Total = dt.Compute("Sum(数量)", "[配送日期] >= today()")
    Output.Show(Customer & ":" & Total)
Next


--  作者:Bin
--  发布时间:2013/10/22 15:50:00
--  
请上个例子,而且你希望统计到哪里,也没有说清楚.
--  作者:有点甜
--  发布时间:2013/10/22 20:15:00
--  
 参考下面的代码

Dim dt As DataTable = DataTables("社员消费明细")
Dim Total As Integer
Dim Customers As List(Of String)
Customers = dt.GetValues("数量")
For Each Customer As String In Customers
    Total = dt.Compute("Sum(数量)", "[配送日期] >= #" & Date.Today & "# and 社员 = \'" & Customer & "\'")
    Output.Show(Customer & ":" & Total)
Next