Hi
I have this sql running which works ok, basially show potential duplicte customers by uprn and orders (DESC) by datelastmodified for the customer. problem is say a MR. SMITH is the first record (because somebody has just created him 2 minutes ago) his duplicate may have been created 2 months ago so in the query/report
a) because the uswer wants dat parameters it may not even show
b) if it does the user has to look through pages of records to find them
what i'd like is to keep the ordering by datelastmodfied DESC, so show the most recent entry for MR. SMITH at the top (MAX(a.datelastmodified) ?), but beneath have the duplicate also ?
any help appreciated
gaz
I have this sql running which works ok, basially show potential duplicte customers by uprn and orders (DESC) by datelastmodified for the customer. problem is say a MR. SMITH is the first record (because somebody has just created him 2 minutes ago) his duplicate may have been created 2 months ago so in the query/report
a) because the uswer wants dat parameters it may not even show
b) if it does the user has to look through pages of records to find them
what i'd like is to keep the ordering by datelastmodfied DESC, so show the most recent entry for MR. SMITH at the top (MAX(a.datelastmodified) ?), but beneath have the duplicate also ?
any help appreciated
gaz
Code:
SELECT LEFT(a.SURNAME, 24) AS Surname, b.UPRN, a.CUSTOMERID,
a.DATELASTMODIFIED
FROM CUSTOMERS a INNER JOIN
CUSTOMERADDRESS b ON a.CUSTOMERID = b.CUSTOMER
WHERE ((a.SURNAME + ISNULL(b.UPRN, '')) IN
(SELECT a.surname + isnull(b.uprn, '')
FROM CUSTOMERS a, CUSTOMERADDRESS b
WHERE a.customerid = b.customer
GROUP BY a.surname, b.uprn
HAVING COUNT(*) > 1))
ORDER BY a.datelastmodified, b.UPRN, LEFT(a.SURNAME, 24), a.CUSTOMERID