Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-12-07 : 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
30421 Posts |
Posted - 2006-12-07 : 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 LarssonHelsingborg, Sweden |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-07 : 08:36:12
|
You should post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|