Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: simultaneous subreports Post Reply Post New Topic
Author Message
Vithi5
Newbie
Newbie
Avatar

Joined: 04 Dec 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote Vithi5 Replybullet Topic: simultaneous subreports
     Posted: 17 Dec 2008 at 5:03am
Hello,
 
I have posted this issue b4 and have gotten good feed back, but not what i am looking for.  I cannot seem to find my posting.  I'll try to explain my problem a little better.
 
I have to work with 2 tables from a database. 
Table A
ID
12345
23455
52156
54213
 
Table B
ID            Value     Date     
12345        z          2005/01/08           
12345        z          2005/01/11
12345        x          2005/01/09
23455        y          2007/05/04
23455        y          2007/05/09
23455        x          2007/06/01
52156        z          2008/01/01
54213        z          2008/01/09
54213        y          2008/01/11
 
Table A and B are connected by the ID.  I have to get the z, y, and x and get the latest Date for each ID.
In crystal, it should display such as this:
 
ID                Value z Latest Date  Value y Latest Date   Value x Latest Date
12345                  2005/01/11               -                                 2000/01/09
23455                              -                 2007/05/09                   2007/06/01  
52156                  2008/01/01                      -                                    -
54213                  2008/01/09           2008/01/11                              -
 
but this is how it is displayed now,
ID                Value z Latest Date  Value y Latest Date   Value x Latest Date
12345                  2005/01/11              
                                                                  -                                                                                                        2000/01/09
23455                              -                                                              2007/05/09                   
                                                                                           2007/06/01  
52156                  2008/01/01                     -                                    -
54213                  2008/01/09           
                                                                2008/01/11                             
                                                                                               -
 
It's leaving spaces.  this happens when i place the supreport z into group header and the subreport y into the Details.  If i were to place both subreports in Details, 2 detail are being created in Preview and they are not placed right beside each other.
 
I need to create 3 subreports, but if it can be done in one, it would be great too.  I have tried to create it in one.  same issue. i ran the subreport separately.  the values are not beside each other.
 
Please help me.
Thank you.
Thank you.
Vithi
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 17 Dec 2008 at 12:49pm

Hi

 You can do in single SQL create View or use Command Object use the SQL Below

 
SELECT
DISTINCT TB.ID,
MAX(Z.D_DT)'Z',
MAX(Y.D_DT)'Y',
MAX(X.D_DT) 'X'
FROM TB --- Table B
left join TB Y        ON  Y.ID  =  TB.ID AND Y.VAL='Y'
LEFT JOIN TB X  ON  X.ID = TB.ID  AND X.VAL='X'
LEFT JOIN TB Z   ON Z.ID = TB.ID  AND Z.VAL ='Z'
GROUP BY TB.ID,TB.VAL

Cheers
Rahul


Edited by rahulwalawalkar - 18 Dec 2008 at 12:26am
IP IP Logged
Vithi5
Newbie
Newbie
Avatar

Joined: 04 Dec 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote Vithi5 Replybullet Posted: 18 Dec 2008 at 7:53am
Thank you for your help.  Appreicate it.
 
 
Thank you.
Vithi
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum