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-09-13 : 06:34:01
|
Luke writes "I need to pull from email address field with no duplicates.******************SELECT DISTINCT dbo.tblDealer.EmailPrimary, dbo.tblDealership.DealershipTypeID, dbo.tblDealer.FirstName, dbo.tblDealer.LastNameFROM dbo.tblDealer INNER JOINdbo.tblDealership ON dbo.tblDealer.DealerID = dbo.tblDealership.DealerIDWHERE(dbo.tblDealership.DealershipTypeID = 2) AND (dbo.tblDealer.EmailPrimary > '') ORDER by EmailPrimary ASC*******************This works fine but the DISTINCT seems no to work after I add other fields.I have tried SELECT (DISTINCT (dbo.tblDealer.EmailPrimary)), and others with no success.I also tried using COUNT only 1 Email Address still no luck.The next step is to copy these results to another table tblGroup1 and have them update regularly (but a problem for another day)" |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-09-13 : 06:54:29
|
If you want on column to be distinct what do you want to do with the other columns in the resultset?distinct has to work on the complete row or it doesn't make sense.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-09-13 : 09:55:35
|
Hack:SELECT DISTINCT EmailPrimary FROM(SELECT D.EmailPrimary, DS.DealershipTypeID, D.FirstName , D.LastNameFROM tblDealer DINNER JOIN tblDealership DSON D.DealerID = DS.DealerIDWHERE DS.DealershipTypeID = 2 ) a [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|
|