我按客户/帐号显示交易摘要。事务有两个可能的组件,硬件或软件 我希望用户获得具有帐户总数的演示文稿,或单独显示的硬件和软件总计。
目前,向用户提供的唯一选项是单独获取它们。为了实现这一点,我有一个带有连接的子查询,其on语句当前为
on tb3.account_nbr=tb4.account_nbr and tb3.trans_type=tb4.trans_type
取消对该语句的trans_type评估将返回帐户上所有交易的总计。
我在表单上添加了一个复选框,表示他们希望分别获取总计或两个组件。结果变量(@get_trans)值为“1”表示为按事务类型单独的总计,或“0”表示所有事务类型的总和并显示为单个总计。
有意义的是,我可以将上面的内容更改为解决方案的if语句,但它无法正常工作
on tb3.account_nbr=tb4.account_nbr and if(@get_trans=1,tb3.trans_type=tb4.trans_type,"")
任何帮助将不胜感激。 谢谢, 吉姆
答案 0 :(得分:0)
问题可能是on
子句。在此上下文中,空字符串将计算为if
- 并将其视为false。这会导致整个on tb3.account_nbr = tb4.account_nbr and
(@get_trans <> 1 or tb3.trans_type = tb4.trans_type)
条件为假。
但是,您可以在没有@get_trans
:
NULL
注意:此版本假定on tb3.account_nbr = tb4.account_nbr and
(@get_trans <> 1 or @get_trans is null or tb3.trans_type = tb4.trans_type)
不会使用google.visualization.LineCHart
值。这很容易处理:
explorer