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

Can an entity have two primary keys?

0 Answers  


What is the meaning of resultset type_scroll_insensitive?

0 Answers  


How to Handle the exceptions in Sqlsrver 2005??

3 Answers   Value Labs, Wipro,


what is for foreign key ??

4 Answers   CarrizalSoft Technologies, Sabic,


What objects does the fn_my_permissions function reports on? : sql server security

0 Answers  






wht is normalization?can u explain me in detail?

9 Answers   TCS,


how many non clustered index in sql server 2008,2010,2012

2 Answers   Accenture,


from the table display the 2nd highest salary? and also the least 2nd salay?

8 Answers  


i have a table student like sname ----- ram ram ram raj raj raj i need the output like sname ----- ram raj ram raj ram raj

9 Answers   IBM,


How do you make a trace?

0 Answers  


how many joins we can write if at all we have n no of tables

5 Answers   Tanla Solutions, TS,


WHAT OPERATOR PERFORMS PATTERN MATCHING?

2 Answers   CarrizalSoft Technologies, CTS,


Categories