以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]多条件统计  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=196116)

--  作者:苏州老街
--  发布时间:2025/3/30 16:25:00
--  [求助]多条件统计
老师好,我想在“房屋主体”后面再加一个统计条件“单间名称”


If e.DataCol.name = "年" OrElse e.DataCol.name = "房屋主体" Then
    If e.DataRow.Isnull("年") = False AndAlso e.DataRow.Isnull("房屋主体") = False Then
        Dim filter1 As String = "名称_房屋主体 = \'" & e.DataRow("房屋主体") & "\'"
        For i As Integer = 1 To 12
            Dim d As Date = new Date(val(e.DataRow("年")), i, 1)
            Dim sum As Integer = DataTables("租房数据汇总").compute("sum(累计缴费)", filter1 & " and 抄表日期 >= #" & d & "# and 抄表日期 < #" & d.addmonths(1) & "#")

--  作者:有点蓝
--  发布时间:2025/3/30 20:47:00
--  
用法不都一样吗,使用and连接多个条件即可:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=196048&skin=0
--  作者:苏州老街
--  发布时间:2025/3/31 4:44:00
--  
老师,这个统计条件“单间名称”要加到下面代码中吗?

If e.DataCol.name = "年" OrElse e.DataCol.name = "房屋主体" Then
    If e.DataRow.Isnull("年") = False AndAlso e.DataRow.Isnull("房屋主体") = False Then
        Dim filter1 As String = "名称_房屋主体 = \'" & e.DataRow("房屋主体") & "\'"

--  作者:有点蓝
--  发布时间:2025/3/31 8:40:00
--  
要加
--  作者:苏州老街
--  发布时间:2025/3/31 13:55:00
--  
老师,没有改好,标出的是原来的代码,没标出的代码该不好。

\'If e.DataCol.name = "年" OrElse e.DataCol.name = "单间名称" Then
    \'If e.DataRow.Isnull("年") = False AndAlso e.DataRow.Isnull("单间名称") = False Then
        \'Dim filter1 As String = "名称_单间名称 = \'" & e.DataRow("单间名称") & "\'"


If e.DataCol.name = "年" OrElse e.DataCol.name = "房屋主体"  OrElse e.DataCol.name = "单间名称" Then
    If e.DataRow.Isnull("年") = False AndAlso e.DataRow.Isnull("房屋主体") AndAlso e.DataRow.Isnull("单间名称") = False Then
        Dim filter1 As String = "名称_房屋主体 = \'" & e.DataRow("房屋主体") And "名称_单间名称 = \'" & e.DataRow("单间名称") & "\'"


--  作者:有点蓝
--  发布时间:2025/3/31 14:02:00
--  
.....e.DataRow("房屋主体") And 名称_单间 ...
--  作者:苏州老街
--  发布时间:2025/3/31 14:19:00
--  
老师,是这个地方面


 Dim filter1 As String = "名称_房屋主体 = \'" & e.DataRow("房屋主体") And "名称_单间名称 = \'" & e.DataRow("单间名称") & "\'"


--  作者:有点蓝
--  发布时间:2025/3/31 14:21:00
--  
多个双引号
--  作者:苏州老街
--  发布时间:2025/3/31 14:28:00
--  
老师,去掉双引号报错

图片点击可在新窗口打开查看此主题相关图片如下:2025-03-17 12 19 54.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2025/3/31 14:30:00
--  
Dim filter1 As String = "名称_房屋主体 = \'" & e.DataRow("房屋主体") & "\' And 名称_单间名称 = \'" & e.DataRow("单间名称") & "\'"