I have data in two tables (see below for a sample) - how do I create a Crystal report (more of a "score card" really) displaying only sum(table1.column1) and sum(table2.column1) with no other details? When I try, one of the sums gets way too big, indicating it has been included in some inner loop in the calculations.
Table1:
Column1: Integer
Column2: Varchar(100)
...
Table2:
Column1: Integer
Column2: Varchar(50)
...
Note - there are no joint keys, the only relation between the tables is that they relate to the same business area.
select t1.cnt, t2.cnt
from ( select count(*) cnt from table1 where... ) t1
, ( select count(*) cnt from table2 where... ) t2
If you want to avoid the sub-query approach, the only real route that I can think of is to use sub-reports.
2 ways I can think of:
I answer this with the caveat that it will almost certainly be slower than simply using one query (as in Randy's answer), because Crystal Reports is not as efficient as the DB engine. It's also probably going to be harder than maintain. Basically, while you certainly can do it this way, I'm not sure I would .
You could use two SQL Expression fields. Each field needs to return a scalar value. You can correlate (link) each query with the main-report's query as well.
The first one obviously requires (1) a unique key in Table1 and (2) printing the values in the footer. If those constraints won't work, two subreports should still work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.