Author |
Message |
clutch69rs
Newbie
Joined: 21 Jul 2017
Online Status: Offline
Posts: 3
|
Topic: Separate groups Posted: 24 Jul 2017 at 5:14am |
Hi, I have 2 sets of data to pull in, from 2 separate tables. The data in set 1 and set 2 is not related in any way.
Set 1: apples, oranges, bananas, grapes
Set 2: red, blue, yellow, green, purple
I have the above sets grouped separately in the group footer on fruit.table and color.table.
Is it possible to pull in the results for set 1 without affecting the results for set 2? That is, I'm seeing set 1 repeat when set 2 loads a result. Set 1 will repeat x number of times, with x being the number of results from set 2. I understand that I could do what I need from a subreport, but this particular report is already a subreport of a much larger report. Thanks in advance for any help or advice for this novice user :)
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 24 Jul 2017 at 5:41am |
If possible consider using a union statement in a stored proc or crystal command to create one result set to use
|
IP Logged |
|
clutch69rs
Newbie
Joined: 21 Jul 2017
Online Status: Offline
Posts: 3
|
Posted: 24 Jul 2017 at 7:46am |
Thanks, Dblank. I've tried a union statement and a crystal command; the results still repeat. apple red apple blue apple yellow oranges red oranges blue oranges yellow ...etc ..etc.
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
Posted: 24 Jul 2017 at 8:46am |
since that data is unrelated, it sounds like you will get a cartesian product every time if you join them.
in a stored proc you could select all of one table into a temp table and then select the other table into the temp, that would eliminate the duplication.
I would think that 2 select statements unioned together like DBlank suggest should work in a similar fashion.
my two cents
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
Posted: 24 Jul 2017 at 9:12am |
agreed with lockwelle
the two tables with cross join if you just pull them in with no join (this happens when you use one field from each table. The union command needs to replace the use of each separate table.
The union would be
select fruitname as ObjectName, 'Fruit' as ObjectType from fruittable
UNION
select colorname as ObjectName, 'Color' as ObjectType from colortable
that should give you one unified result that becomes your source
Edited by DBlank - 24 Jul 2017 at 9:13am
|
IP Logged |
|
clutch69rs
Newbie
Joined: 21 Jul 2017
Online Status: Offline
Posts: 3
|
Posted: 24 Jul 2017 at 9:19am |
Thanks so much, lockwelle and DBlank. That did the trick.
|
IP Logged |
|
|