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)
 difficult query

Author  Topic 

terry06
Starting Member

1 Post

Posted - 2006-05-09 : 13:18:17

Thanks a mil, Both worked a treat.
Terry

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-09 : 13:30:39
[code]
SELECT A, B
FROM
(
SELECT A, B, COUNT(*) AS Cnt
FROM YourTable
GROUP BY A, B
) t
WHERE Cnt = 1
[/code]

Tara Kizer
aka tduggan
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2006-05-09 : 13:41:01
SELECT A, B
FROM dbo.Mytable
GROUP BY A, B
HAVING (COUNT(B) = 1)

by Tara

Jim
Users <> Logic
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-09 : 13:44:53
Yours is better though. I just didn't think of HAVING in this case even though I use it quite a bit.

Tara Kizer
aka tduggan
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-10 : 04:47:01
quote:
Originally posted by terry06


Thanks a mil, Both worked a treat.
Terry


Instead of editing the question, you should post your opinion as new reply

Madhivanan

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

- Advertisement -