Click here to Skip to main content
15,063,287 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table named "WorkingGroupSchoolContact" with fields "SchoolID" and "ContactID".
Now we have quite number of duplicate entries in the field "ContactID". We can have duplicate entries of the "ContactID" for the same "SchoolID" but the same "ContactID" should be present for two or more different "SchoolID". Now I have to filter data based on the condition. Can anyone please help me to perform this operation.
Posted
Updated 21-Aug-15 1:35am
v2

1 solution

Hello,

Please try below query:

SQL
select ContactID,SchoolID,COUNT(ContactID) as DuplicateNumbers from WorkingGroupSchoolContact
group by ContactID,SchoolID
Having COUNT(ContactID) > 1


This query will return all the duplicate records in the combination of ContactID and SchoolID.

Please let me know if you have any concern or query on this or if I am missing something.


Thanks
   
v2
Comments
user 3008 21-Aug-15 9:55am
   
Thank you so much for your response.

what is the UserId? Where did you declare that?
Advay Pandya 21-Aug-15 10:17am
   
Ohh Sorry, It's my column name. Let me edit that. Please check now

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900