Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Data Selection and Counts Post Reply Post New Topic
Author Message
CigJDD
Newbie
Newbie


Joined: 03 Jun 2015
Online Status: Offline
Posts: 3
Quote CigJDD Replybullet Topic: Data Selection and Counts
     Posted: 30 Jun 2015 at 6:30am
Good Day All,
 
I have a query that involves two linked tables that looks something like the example below(Linked on Provider ID):
 
Table A                                    Table B
ProviderID (Primary Key)           ProviderID(not Primary Key)     Date
prov123                                    prov123                                  1/1/2000
prov124                                    prov123                                  1/2/2000
prov125                                    prov125                                  1/3/2000
 
I am looking to create a query that returns one(and only one) Max Date for each provider in Table A.  At the same time I need the count of returned data to reflect only the count of providerid's in table A.
 
I am gong to use a cross tab to do this.
 
What I am running into is that the counts reflect the total number of records in table B no matter how I put the data together.  So prov123 would have a count of 2 when there really there is only 1 Max Date for prov123.
 
Im thinking that I need to somehow get the Select expert to only recognize the max date for the date field in Table B but am not sure how to do it.  Any thoughts?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jun 2015 at 10:55am
pulling in only the maxdate will have to be done using a source of data to accomplish that.
If this is only about counting just use a distinctcount.
You also did not mention about records in A and not in B (prov124). I am guessing you are doing more with the counts or summaries but without knowing this it is hard to tell what direction to go in.
If you can write a command or stored proc doing a grouped max on B and joining that (maybe a left join) to A is the simplest solution.
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