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 can I create a new template for import ? : sql server management studio

0 Answers  


What is 4nf in normalization form?

0 Answers  


what is the difference between openrowset and openquery?

0 Answers  


What is difference between drop truncate and delete?

0 Answers  


What should we do to copy the tables, schema and views from one SQL Server to another?

3 Answers  






How to avoid cursors?

3 Answers   CarrizalSoft Technologies, HP,


How can delete duplicate records in cte in sql server?

0 Answers  


What is the difference between for auto and for nested?

0 Answers  


Why is the need for data conversion transformations?

0 Answers  


What are the different types of collation sensitivity?

0 Answers  


Explain raiserror in sql server?

0 Answers  


where do you use Isolations?give me some exmpale?

1 Answers  


Categories