Filter out duplicate records using address in Query

BukHix

Registered User.
Local time
Today, 07:21
Joined
Feb 21, 2002
Messages
379
I am pulling data from an application that allows duplicate customers (Not sure why but it does). Here is my SQL as it is:

Code:
SELECT CUSTOMER.FIRSTNAME, 
CUSTOMER.LASTORCOMPNAME, 
CUSTOMER.ADDRSTR1, 
CUSTOMER.ADDRCITY, 
CUSTOMER.ADDRSTATE, 
Left([ADDRZIPANDEXT],5) AS Zip, 
HISTORY.CLOSEDATE, 
HISTORY.JOBSTATUS
FROM CUSTOMER INNER JOIN HISTORY ON CUSTOMER.CUSTID = HISTORY.CUSTID
WHERE (((HISTORY.CLOSEDATE)>#7/6/2004#) 
AND ((HISTORY.JOBSTATUS)=1 Or (HISTORY.JOBSTATUS)=2 Or (HISTORY.JOBSTATUS)=3))
ORDER BY CUSTOMER.LASTORCOMPNAME, HISTORY.CLOSEDATE DESC;

Is there anyway to make it so that when a duplicate street address is shown my query will only pull the first one and ignore the rest?
 
you can try using SELECT DISTINCT but if any of the returned data is different than it will not work. I would concern myself more with why data is duplicated than anything else and find a way to fix that.
 
I have no way to change the data structure. It is a very expensive commercial application that my employer is using. I am bascialy just importing a couple of tables from the app into mine and then trying to create a customer follow up list. As you can guess when we want to create mailing labels we get all kinds of redundant info.

I will try the select distinct to see if that will take care of it. This is the kind of thing that even if we only got 90% of what we wanted it would be ok. 90% still beats the hell out of hand writing out all the addresses.
 

Users who are viewing this thread

Back
Top Bottom