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
 General SQL Server Forums
 New to SQL Server Programming
 Report unique entries

Author  Topic 

musiqueman
Starting Member

2 Posts

Posted - 2006-12-01 : 13:06:23
e.g. column name: nameID, projectID)

2, 123
3, 213
3, 243
4, 987
5, 243
5, 213

I want the result to be:

2, 123
4, 987

How would I write the query?

Thanks in advance.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-12-01 : 13:15:32
Here's one way:


select [name]
,min(projectid) projectid
from (
select 2 [name], 123 projectid union all
select 3, 213 union all
select 3, 243 union all
select 4, 987 union all
select 5, 243 union all
select 5, 213
) a
group by name
having count(*) = 1


Be One with the Optimizer
TG
Go to Top of Page

musiqueman
Starting Member

2 Posts

Posted - 2006-12-01 : 15:56:58
Wonderful. Thanks!!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-04 : 09:49:35

http://sqlteam.com/forums/topic.asp?TOPIC_ID=6256

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -