我如何在Crystal Report中对ID为某个数字的列上的数据求和 [英] How do I in Crystal Report sum data on a column where id is some number

查看:93
本文介绍了我如何在Crystal Report中对ID为某个数字的列上的数据求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Crystal Reports的新手,并且已经尝试了一段时间。我正在运行Crystal Reports XI。请帮忙。

I am new to Crystal Reports and have been trying to figure this out for a while. I am running Crystal Reports XI. Please Help.

The data:
 john respMonitor    5
 abe  case mgmt      4   
 Cy   test1          4
 Claire respMonitor  5
 Moe   test3         2 
 Bob   case mgmt     8
 Lynn  respMonitor   4 
 Rick  test2         33
 Ray   test1         31
 Al    test1         24
 etc. 

我要创建以下数据:

group           cost
 sumOfTests1_3      124.0  <====== want a sum of tests only
 respMonitor     5.0
 caseMgmt        7.0
 respMonitor     3
 respMonitor     2
 caseMgmt        4
 etc.

所以我只想总结测试,而其他组别留在这里。

So I want to be able to only sum up the tests while leaving the other groups alone.

I created a sql expression field:
 {%testCM}
(
SELECT sum("Patient"."cost") From PatientTbl 
    Where "PatientTbl"."group"= 'test1' OR
    "PatientTbl"."group"= 'test2' OR
    "PatientTbl"."group"= 'test3' 
)

In my Record Selection I have:
 {PatientTbl.group} in ["respMonitor","case mgmt", "test1","test2","test3"]

I also created a formula field:
 If {PatientTbl.group} in ["test1", "test2","test3"] Then
      {%testCM}

是否应该有其他公式字段中的-block以打印其余部分?
我看不到如何仅汇总测试组的成本,而又不让其他组单独打印。不知道从这里去哪里。

Should there be an Else-block in the formula field to print out the rest? I don't see how to sum up only the costs for group "test" while leaving the other groups to still be printed out individually. Not sure where to go from here.

谢谢,
约翰

推荐答案

我不认为您不需要SQL表达式。只需添加此公式并将其用作您的组表达式,然后求和即可。花费一个的组仍然会显示正确的值。

I don't think you need a SQL expression. Just add this formula and use it as your group expression and then sum the costs. A group with one cost will still show the right value.

if {PatientTbl.group} in ["test1", "test2","test3"] Then
    "Test1-3"
else
    {PatientTbl.group}

这篇关于我如何在Crystal Report中对ID为某个数字的列上的数据求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆