Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Ask SQLTeam Question

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,, h.productCode AS

product_code, DATEDIFF(dd, GETDATE(), h.expirationDate)

AS Difference, h.hotSyncId AS regcode, od.autorenewal AS autorenewal, od.installment AS


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 ( <> 'University of Alberta')

ORDER BY difference, c.Last_Name, h.productCode"

Patron Saint of Lost Yaks

30421 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

Premature Yak Congratulator

22864 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


Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000