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.
| Author |
Topic |
|
seekaye
Starting Member
6 Posts |
Posted - 2012-11-04 : 05:14:27
|
| HiMy table looks like this: Surname Forename Clss ColourAnna Archibald A GreenAnna Archibald A BlueAnna Archibald B RedBill Blackman A RedBill Blackman B GreenChris Cardman C GreenChris CardMan C BlueI want to return all the records where a person is in the same classe.g.Anna Archibald A GreenAnna Archibald A BlueChris Cardman C GreenChris CardMan C BlueI've got as far as SELECT surname,forename,class FROM mytableGROUP BY surname,forename having count(*) > 1which returnsAnna Archibald CChris CardMan CThanks for any help |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-11-04 : 08:59:44
|
| [code]SELECT * FROM( SELECT *, COUNT(*) OVER (PARTITION BY Surname,Forname,Clss) AS N FROM mytable)s WHERE N > 1[/code] |
 |
|
|
|
|
|