employee table has employee id
-----------
empid
----------------
1
2
3
3
3
4
5
5
5
6
6
6
7
here the values r repeated two times.how to select the
repeated values only.i.e 3,5,6 should alone come.

Answers were Sorted based on User's Feedback



employee table has employee id ----------- empid ---------------- 1 2 3 3 3 4 5 5 5 6 ..

Answer / vijendra singh shakya

For Employee table plz use the following Query...

select [empid] from employee group by [empid]
having count(empid)>1

Is This Answer Correct ?    17 Yes 0 No

employee table has employee id ----------- empid ---------------- 1 2 3 3 3 4 5 5 5 6 ..

Answer / meher

If you want to get the count for the duplicates then, the
query will be:

SELECT EMPID,COUNT(EMPID) FROM EMPLOYEE GROUP BY EMPID
HAVING COUNT(EMPID)>1

Is This Answer Correct ?    4 Yes 1 No

employee table has employee id ----------- empid ---------------- 1 2 3 3 3 4 5 5 5 6 ..

Answer / rajesh kumar

select empid from employee where empid in (select empid
from employee group by empid having count(empid) > 1)

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL Server Interview Questions

How to select all columns of all rows from a table with a select statement in ms sql server?

0 Answers  


How to create a simple user defined function in ms sql server?

0 Answers  


in how many ways we can use count()

2 Answers  


How much space does sql server 2016 take?

0 Answers  


How to list all tables having unique constraints in any of the columns in a database.

1 Answers  






What is a deadlock and what is a live lock? How will you go about resolving deadlocks?

7 Answers   Microsoft,


how to insert the values in 5 table at a time Using any single statement ?

6 Answers   Infosys, Value Labs,


How to enable tcp/ip protocol on a sql server?

0 Answers  


What do you mean by authentication modes in sql server?

0 Answers  


Explain what are partitioned views and distributed partitioned views?

0 Answers  


how do u do Performance tunning ?

1 Answers   Infodat Technologies, Satyam,


What is subquery in sql?

0 Answers  


Categories