Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Eliminate Duplicate Records Post Reply Post New Topic
Author Message
miamitourism
Newbie
Newbie
Avatar

Joined: 14 Jan 2011
Online Status: Offline
Posts: 24
Quote miamitourism Replybullet Topic: Eliminate Duplicate Records
     Posted: 25 Mar 2011 at 4:55am

Hi forum!

I am a VERY new user of Crystal and need some help figuring out how to eliminate duplicate records from my reports. 
 
I have a client table {cli_clients} and a dues amount table {ip_dues}. I am running a very simple report of all clients and their annual dues amounts {ip_dues.dues_amt}. As each year passes, a new dues amount is added to each client's record, so many have 2,3,4 or more dues amounts in the table.  There are 2 things I need to be able to do:
 
-In the case of one report, I need to tell Crystal to return only records with the most recent dues amount (which may be this year, or last year or from ten years ago in the case of clients who have not paid since then).
 
-In the case of another type of report which calls for a different set of data but from the same database and with the same problem, I need to tell Crystal to return only the first occurrence.
 
Thanks for your suggestions in advance!
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 25 Mar 2011 at 5:50am
If you know SQL, then it should be easier to get exactly what you want rather than filtering out what you don't want in crystal. It would also be better performance-wise since you know exactly what you want and therefore only get that.

Simply write your SQL query and add a Command to the report rather than selecting all of the tables when you're choosing your data source.

The recent amounts due report should be a matter of stating a where clause that specifies the date range. If the client wishes to specify his own date range, then you have the option of using parameters in the Command.

The second report I'm not sure what is meant by "first occurrence". Is it because there are duplicates? Or perhaps you want a list of unique customers rather than a list of all of the amounts that are due?
IP IP Logged
miamitourism
Newbie
Newbie
Avatar

Joined: 14 Jan 2011
Online Status: Offline
Posts: 24
Quote miamitourism Replybullet Posted: 25 Mar 2011 at 6:04am
Thank you for your advice.
 
Regarding the recent amounts due report- I cannot specify a date range here because I need the report to include whatever the "current" dues amount is. The issue is that not all records in the database are for current members. So, there are some members that haven't paid in 5 years and therefore do not have a dues amount for the current year, or even for several years, but I do need them included in the report. Any ideas on how to do this? Perhaps I can treat this as the "last occurrence", meaning that the query is looking for the "most recent" date associated with that dues amount.
 
Regarding the second report, what I mean by "first occurrence"- yes, I am getting duplicates. Example- I have a list of customers for which my company generated leads.  In some cases the leads were revised and re-sent, and if I create a report asking for all leads, it will give me multiple results for the same lead because of the revisions. I am only interested in the first time that lead was sent out, and this is what I mean by "first occurrence".

Since I am such a new user and couldn't begin to try and write a query if I tried, I'd appreicate if you would make a suggestion as to what these commands should look like.
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 25 Mar 2011 at 6:25am
I interpreted the first report incorrectly.
This is a solution:

1: get all of the amounts due for all , ordered by date

2: create a group based on the clients. Each record in each group should be sorted by date from most recent to earliest (since the query ordered records by date). Since you are only interested in the most recent amount, you can move the "amount due" field into the group header. This should give you the most recent one as it should be the first record.

If you don't want to learn SQL, you can still create the report. You would pick the tables when you're first choosing the data source and then simply drag and drop the correct fields onto the report. You might need to do a little more sorting and grouping though.

I've never done that so I'm not sure how that would work

But if you are interested in learning SQL, which I recommend, there are many guides out there.

The query would look like pretty much any other SQL statement:


select client, amount, date
from cli_clients
order by date desc


You can do the second report after you finish the first one. I think the first one is easier.

Edited by Keikoku - 25 Mar 2011 at 6:35am
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