Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
e.g. column name: nameID, projectID)2, 1233, 2133, 2434, 9875, 2435, 213I want the result to be:2, 1234, 987How 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) projectidfrom ( 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 ) agroup by namehaving count(*) = 1