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 2000 Forums
 SQL Server Development (2000)
 How to select the none "duplicate" rows?

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2006-10-20 : 15:36:37
Hi, everybody,

I have sample data like this. How can I run a select to get the none "duplication" rows? In this case, it should return rows that id=2, id=3 and the 2nd id=1, ie. the one with values in both email1 and email2 columns.

create table #Namez
(id int,
email1 char(20) null,
email2 char(20) null)
go

insert into #Namez values (1, 'Mom@msn.com','')

insert into #Namez values (1, 'Mom@msn.com','sis@mcn.com')

insert into #Namez values (2, 'dad@msn.com','')

insert into #Namez values (3, '','Mob@msn.com')

go
Thanks!

Hommer
Aged Yak Warrior

808 Posts

Posted - 2006-10-20 : 16:08:52
Ok, I got it.
select email1, max(email2) from #Namez group by email1
Go to Top of Page
   

- Advertisement -