Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Deleting duplicate records Post Reply Post New Topic
Author Message
lions_share
Newbie
Newbie


Joined: 23 Mar 2007
Location: United States
Online Status: Offline
Posts: 4
Quote lions_share Replybullet Topic: Deleting duplicate records
    Posted: 26 Apr 2007 at 8:46am
I am in the process of designing a report to filter customers by mailing address. Some of our customers have several family members listed on their account with the same mailing address. Right now if we have a bulk mailing then some of our customers will get 3 or 4 brochures due to duplicate addresses in the database.

I grouped the data by mailing address and chose 'Suppress if Duplicated' in the format editor. This suppresses the data but is there a way to eliminate the record from the report entirely? For example in the lower right the record count may be 9500 and I want to get rid of the records that contain duplicate addresses to bring the count to 8900 or whatever.

Any help is appreciated. I'm running CR 9 from a SQL Server DB using ODBC.

Thanks.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 26 Apr 2007 at 8:52am
Have you tried going to the Database menu and turning on Select Distinct Records?  I'm not sure if this will work in your case, though - it won't if you include the customer name and multiple names have the same mailing address. 
 
Also, the count at the bottom of the screen is not always the most accurate way of determining how many records are on the report - if any of your record filtering happens in Crystal instead of on the database, there will be more records read that will actually appear on the report.  A better way of determining how may records are actually on the report would be to include a DistinctCount of the mailing address field in the report footer.
 
-Dell
IP IP Logged
lions_share
Newbie
Newbie


Joined: 23 Mar 2007
Location: United States
Online Status: Offline
Posts: 4
Quote lions_share Replybullet Posted: 26 Apr 2007 at 9:11am
I did in fact try the Select Distinct Records but it did not work for the reason that you indicated. Thank you for your reply.
IP IP Logged
vivekvarma
Newbie
Newbie
Avatar

Joined: 03 May 2007
Location: India
Online Status: Offline
Posts: 6
Quote vivekvarma Replybullet Posted: 03 May 2007 at 1:30am

hi,

   use distinct in your query and select top1 .this may help ur requirement
regards,
vivek varma
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 03 May 2007 at 6:23am
vivekvarma,
 
Distinct won't work in this situation - the addresses are the same but the names that go with them aren't.
 
-Dell
IP IP Logged
EscApe
Newbie
Newbie


Joined: 13 Nov 2006
Location: Finland
Online Status: Offline
Posts: 37
Quote EscApe Replybullet Posted: 07 May 2007 at 4:09am
Have you tried grouping on sql command:

select max(name), address, city, state, max(country)
from table db1
where expressions
group by address, city, state
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 07 May 2007 at 7:49am
EscApe,
 
You're answer will work if you're using CommandText.  However, Crystal doesn't allow CommandText for all databases.  The way to get Crystal to handle this in all situations is, as I stated above, set a group on the address and then put all of the information you need in either a group header or footer.
 
-Dell


Edited by hilfy - 07 May 2007 at 7:50am
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.027 seconds.