Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Displaying duplicates on some fields
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

6 Posts

Posted - 11/04/2012 :  05:14:27  Show Profile  Reply with Quote

My table looks like this:

Surname Forename Clss Colour
Anna Archibald A Green
Anna Archibald A Blue
Anna Archibald B Red
Bill Blackman A Red
Bill Blackman B Green
Chris Cardman C Green
Chris CardMan C Blue

I want to return all the records where a person is in the same class

Anna Archibald A Green
Anna Archibald A Blue
Chris Cardman C Green
Chris CardMan C Blue

I've got as far as

SELECT surname,forename,class
FROM mytable
GROUP BY surname,forename having count(*) > 1

which returns

Anna Archibald C
Chris CardMan C

Thanks for any help

Edited by - seekaye on 11/04/2012 05:21:32

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/04/2012 :  08:59:44  Show Profile  Reply with Quote
		COUNT(*) OVER (PARTITION BY Surname,Forname,Clss) AS N
)s WHERE N > 1
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000