• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 58
  • Last Modified:

selecting duplicate data

Hi, Below is my test data and I need to get only those references with duplicate serial nos. So
for my below data, I only need to get the below result. can anyone please give me that tsql code ?

abcd       14157464
abcd       14157454




reference      serialno

abcd       14157456
abcd       14157464
abcd       14157454
xyz      13542546

Thanks
0
gvamsimba
Asked:
gvamsimba
  • 2
1 Solution
 
Leo TorresSQL DeveloperCommented:
try
Select reference,  serialno, Count(1) counts
from table 
Group by reference,  serialno
Having Count(1) > 1

Open in new window

0
 
Saurabh Singh TeotiaCommented:
You can use below mentioned query...

select reference,serialno
from table1
Having count(serialno)>1

Open in new window


Saurabh...
0
 
gvamsimbaAuthor Commented:
Saurabh your query is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
0
 
gvamsimbaAuthor Commented:
good
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now