Link to home
Start Free TrialLog in
Avatar of gvamsimba
gvamsimbaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Leo Torres
Leo Torres
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use below mentioned query...

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

Open in new window


Saurabh...
Avatar of gvamsimba

ASKER

Saurabh your query is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
good