水晶报表相当于'WHERE' [英] Crystal Reports equivalent of 'WHERE'
问题描述
我熟悉SQL,但不熟悉水晶报表。我要处理的导入数据集包含5列:
id deathDate giftDate giftAmount Dead
123 2008 -01-06 2011-09-08 25.00 TRUE
456 2009-06-08 2011-10-13 10.00 TRUE
789 0 2011-12-04 50.00 FALSE
...
我试图做一个子查询,但不知道什么CR等效的WHERE在SQL中是。我想按照以下行做一些事情:
从tab1中选择count(id)where dead = TRUE
有任何建议吗?
正如Conrad和dotjoe所观察到的,sql 如果您需要在详细信息部分中同时包含true和false 公式如下(假设 使用 类似于在sql查询中包括求和的case值 - 类似于: I'm familiar with SQL but not Crystal Reports. I'm trying to deal with an imported data set with 5 columns: I'm trying to do a subquery but can't figure out what the CR equivalent of WHERE in SQL would be. I'd like to do something along the line of: Any suggestions? As Conrad and dotjoe have observed, the Crystal equivalent of the sql If you need to include both true and false In the Formula editor, enter a formula like the following (assuming Use the This technique is essentially similar to including a summed case value in a sql query - something like: 这篇关于水晶报表相当于'WHERE'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!其中子句的Crystal等同于Select Expert - 您应该可以在报告菜单上找到它。 / p>
Dead
记录,记录 Dead
为真,最简单的方法是设置公式项。为此:
DeadCount
。
Dead
是一个字符串):
如果{tab1。 Dead} ='TRUE'then 1
x-2
按钮(或Alt-C)以检查公式是否没有任何错误,然后按保存并关闭按钮退出公式编辑器。
Sum of @DeadCount
的汇总字段应显示在报表页脚中。 (您现在应该从报表设计区域中删除未汇总的公式字段。)
select sum(当Dead ='TRUE'然后1 end时的情况)作为DeadCount从tab1
id deathDate giftDate giftAmount Dead
123 2008-01-06 2011-09-08 25.00 TRUE
456 2009-06-08 2011-10-13 10.00 TRUE
789 0 2011-12-04 50.00 FALSE
...
SELECT count(id) from tab1 where dead=TRUE
where
clause is the Select Expert - you should be able to find this on the Report menu.Dead
records in the detail section, but want a total for only those records where Dead
is true, the simplest way to do this would be to set up a formula item. To do so:
DeadCount
.Dead
is a string):If {tab1.Dead} = 'TRUE' then 1
x-2
button (or Alt-C) to check that the formula does not have any errors, then press the Save and Close button to exit the formula editor.Sum of @DeadCount
, should appear in the Report Footer. (You should now remove the un-summarised formula field from where you placed it in the report design area.)select sum(case when Dead = 'TRUE' then 1 end) as DeadCount from tab1