Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Comparing current with previous data Post Reply Post New Topic
Author Message
PeterG
Newbie
Newbie
Avatar

Joined: 28 Sep 2010
Location: Canada
Online Status: Offline
Posts: 6
Quote PeterG Replybullet Topic: Comparing current with previous data
     Posted: 30 May 2011 at 7:10am
Hello everyone,
 
I have an existing report that pulls current information. The report pulls information of members who have requested a fee waiver for the current year. How can I make this pull only those who applied for the same waiver from last year and applied again for the same waiver this year?
Here is the SQL from the Crystal report as reference.
 
SELECT Name.ID, Name.CATEGORY, Name_All.BIRTH_YEAR,
        Activity.ACTIVITY_TYPE, Name.FIRST_NAME, Name.LAST_NAME, 
        Name.MEMBER_TYPE, Activity.DESCRIPTION, Name.COUNTRY,
        Activity.PRODUCT_CODE, Activity.TRANSACTION_DATE
FROM   (Name INNER JOIN Activity ON Name.ID=Activity.ID) INNER JOIN Name_All ON Name.ID=Name_All.ID
WHERE  Name.CATEGORY='85_1' AND Activity.ACTIVITY_TYPE='WAIVER'
        AND (Activity.PRODUCT_CODE='85_1 - Maternity Leave' OR Activity.PRODUCT_CODE='85_1 - Paternity Leave')
  AND Activity.TRANSACTION_DATE>='2011-05-26'
 ORDER BY Name.ID
 
I would really appreciate any assistance. I am not a programmer nor a developer.
 
Kind regards,
PeterG
PeterG
Novice User
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 31 May 2011 at 4:26am
If you need a crystal only solution (e.g. no use of sql views or stored procs)
make your select stement grab 2 years worth of data and your category are what you wanted
your where clause)
group on the member (Name.ID)
group on the waiver type (Activity.PRODUCT_CODE)
create a formula to strip the year out of the date field (call it 'flag')
year(Activity.TRANSACTION_DATE)
do a distinct count of this formula at the waiver type group level
do a group select statement to limit your data where this is > 1
distinctcount(@flag,Activity.PRODUCT_CODE)>1
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