Click to See Complete Forum and Search --> : Select emp names


maru143
October 12th, 2006, 04:48 AM
I want to retrieve all employee names from employee
whose joining date is same.

Naumaan
October 12th, 2006, 05:55 AM
select employee_Name from employee where joiningDate In (select joiningDate from ( select JoiningDate,count(joiningDate) CountNum from employee group by JoiningDate) tab1 where tabb1.CountNum > 1 )
/

maru143
October 12th, 2006, 11:23 PM
Thank you very much.

cjard
October 14th, 2006, 04:50 PM
Try to avoid using IN wherever possible. A good rule of thumb is to only use it for lists that youa re typing into the SQL (i.e. x IN (1,2,3) as a shortcut to x=1 OR x=2 OR x=3)

Try not to write SQLs that have IN (SELECT ...) as part.


The query can better be solved like this (sql2005):


SELECT * FROM(
SELECT
e.*,
count(*) over(partition by join_date) as ctr
FROM
emp e
)
WHERE ctr > 1