|
AskSQLTeam
Ask SQLTeam Question
USA
0 Posts |
Posted - 12/07/2006 : 07:53:59
|
Edski writes "Help please, below is my sql query, when I run it, I get the right result with one problem. I get same customers with same email many times. I would only like the same customer shown one time. Checking it by email.
SELECT od.pName, od.dIndx AS dindx, od.pIndx AS pindx, od.device AS device, c.Cust_Id AS cust_id,
c.First_Name AS First_name,
c.Last_Name AS last_name, c.Email AS Email, c.Phone AS phone,c.company, h.productCode AS
product_code, DATEDIFF(dd, GETDATE(), h.expirationDate) AS Difference, h.hotSyncId AS regcode, od.autorenewal AS autorenewal, od.installment AS
installment
FROM Orders_Detail od INNER JOIN
Hot_Sync_ID h ON od.dIndx = h.dIndx INNER JOIN
Customers c ON c.Cust_Id = h.cust_id
WHERE (od.prenewal ='False') and (od.autorenewal = 'no') and (c.newsletter <> 0) AND
(DATEDIFF(dd, GETDATE(), h.expirationDate) = '27') AND (c.company <> 'University of Alberta')
ORDER BY difference, c.Last_Name, h.productCode" |
|
|
SwePeso
Patron Saint of Lost Yaks
Sweden
29138 Posts |
Posted - 12/07/2006 : 08:19:48
|
You will get more than more instance of same customer, if the same customer occurs more than once in the HOT_SYNC_ID table. Which record do you want for each and one customer in the HOT_SYNC_ID table?
Peter Larsson Helsingborg, Sweden |
 |
|