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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select distinct help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2008-02-04 : 14:28:03
SELECT distinct emailAddress FROM emailaddresses WHERE subscribed =1

this works but i really need the emailaddressid field?
how can i get it?
if i do SELECT distinct emailAddress,emailaddressid FROM emailaddresses WHERE subscribed =1 - it's no longer the distinct emails

hey001us
Posting Yak Master

185 Posts

Posted - 2008-02-04 : 14:34:30
SELECT emailAddress, max(emailaddressid) emailaddressid FROM emailaddresses
WHERE subscribed =1 group by emailAddress

hey
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2008-02-04 : 15:10:35
thanks this worked
Go to Top of Page
   

- Advertisement -