Foxtable(狐表)用户栏目专家坐堂 → 条件表达式


  共有2097人关注过本帖树形打印复制链接

主题:条件表达式

美女呀,离线,留言给我吧!
朱女士
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:445 积分:3633 威望:0 精华:0 注册:2020/2/8 11:14:00
条件表达式  发帖心情 Post By:2021/1/28 8:10:00 [只看该作者]

老师您好!

      我要分客户计算数据,由于客户比较多,将大客户单独列出计算,将小客户全归为其他客户,数据合并计算。我用了两种条件表达,但都不计算。我的代码:

    第一种:  Dim qth As String
        qth="[客户]<>'abb' and [客户]<>'魏德曼' and [客户]<>'博瑞' and [客户]<>'博驰'and [客户]<>'望变'"
            
        kgh3=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# " & qth & "And substring([ddlb],1,1)='c '" & " And 发货日期 Is Not null")
        kgh4=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# " & qth & " And substring([ddlb],1,1)='z '" & " And 发货日期 Is Not null")
        ylkje3= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 & "# " & qth & "And substring([ddlb],1,1)='c '")
        ylkje4= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 &  "# " & qth & "And substring([ddlb],1,1)='z '")
     

 第二种:

 kgh3=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# and [客户] Not In ('abb','魏德曼','博瑞','博驰','望变') And substring([ddlb],1,1)='c '" & " And 发货日期 Is Not null")
  kgh4=Tables("ddpsb").Compute("Sum(自产重量)","[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# and [客户] Not In ('abb','魏德曼','博瑞','博驰','望变') And substring([ddlb],1,1)='z '" & " And 发货日期 Is Not null")
  ylkje3= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 &  "# and [客户] Not In ('abb','魏德曼','博瑞','博驰','望变') And substring([ddlb],1,1)='c '")
    ylkje4= Tables("ylckb").Compute("Sum(出库_含税额)","[ckdate]>= #" & dt0 & "# and [ckdate]<= #" & dt3 &  "# and [客户] Not In ('abb','魏德曼','博瑞','博驰','望变') And substring([ddlb],1,1)='z '")
不知道什么原因不统计。请指教! 谢谢!


 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106654 积分:542453 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/1/28 9:17:00 [只看该作者]

有没有加载符合条件的数据?

msgbox("[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# " & qth & "And substring([ddlb],1,1)='c '" & " And 发货日期 Is Not null")

msgbox("[发货日期]>= #" & dt0 & "# and [发货日期]<= #" & dt3 & "# and [客户] Not In ('abb','魏德曼','博瑞','博驰','望变') And substring([ddlb],1,1)='c '" & " And 发货日期 Is Not null")

把上面条件附加到下面sql后面,然后到数据库里查询有没有结果?

select Sum(自产重量) from ddpsb where 

 回到顶部