Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am new to CR and I am using CR V7

Status
Not open for further replies.

HulaGirl

Programmer
Apr 6, 2002
20
US
I am new to CR and I am using CR V7. I am trying to get members' names and address to be printed on mailing lables. I have defined selection criteria in the select expert. However, certain members have multiple records that fall in the range of the selection criteria. As a result Identical names and address printed out multiple times. I tried using SELECT DISTINCT and it did not help, cause they are DISTINCT except for names and addresses. How do get distinct name and address only?? Any tip or suggestion is much appreciated in advance. SQL queries are copied as follow:

SELECT
claimdetail."servcode", claimdetail."dosto",
member."dob",
entity."entname", entity."addr1", entity."addr2", entity."city", entity."state", entity."zip"
FROM
{ oj (((claim INNER JOIN enrollment ON
claim."enrollid" = enrollment."enrollid")
INNER JOIN claimdetail ON
claim."claimid" = claimdetail."claimid")
INNER JOIN member ON
enrollment."memid" = member."memid")
INNER JOIN entity ON
member."entityid" = entity."entid"}
WHERE
(claimdetail."servcode" = 'Z9000' OR
claimdetail."servcode" = '99395' OR
claimdetail."servcode" = '99394' OR
claimdetail."servcode" = '99393' OR
claimdetail."servcode" = '99392' OR
claimdetail."servcode" = '99391' OR
claimdetail."servcode" = '99385' OR
claimdetail."servcode" = '99384' OR
claimdetail."servcode" = '99383' OR
claimdetail."servcode" = '99382' OR
claimdetail."servcode" = '99381')
 
Put only the name and address fields in your "Select Distinct" clause:

SELECT DISTINCT
entity."entname", entity."addr1", entity."addr2", entity."city", entity."state", entity."zip"
FROM ...

and leave the rest of your sql statement as-is.
You don't need servcode, dosto, dob for mailing labels.
 
You cannot edit the SQL via SHOW SQL QUERY in Crystal Reports Designer and add the word DISTINCT. In V8 there is a menu option for DISTINCT, but not in previous versions of Crystal.

Use groups. Add groups to your report. They give you the same functionality as DISTINCT.

These 2 SQL statements are equivalent.

SELECT DISTINCT Customer.Name
FROM CUSTOMER

SELECT Customer.Name
FROM CUSTOMER
GROUP BY Customer.Name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top