SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 edit sql
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 12/07/2006 :  07:53:59  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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
30218 Posts

Posted - 12/07/2006 :  08:19:48  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22755 Posts

Posted - 12/07/2006 :  08:36:12  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
You should post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000