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)
 how to get unique record

Author  Topic 

vojinb
Starting Member

9 Posts

Posted - 2010-12-17 : 07:06:24
Hi,
I'm having table with clients and contracts, contract number is key,one client could have more then one contract.
How can I select clients with only one contract?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-17 : 07:23:02
select * from table t1
join (select clientId from table group by clientId having count(*)=1)dt
on dt.clientId=t1.clientId


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

vojinb
Starting Member

9 Posts

Posted - 2010-12-17 : 07:54:24
Thanks,
it's working
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-17 : 08:02:53
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -