Display the emploee records who joins the department before their manager?

Questions by kowmudiswarna   answers by kowmudiswarna

Showing Answers 1 - 40 of 40 Answers

siva rama srinivas

  • Sep 26th, 2007
 

ans)
         select e.last_name,m.last_name  ,e.hire_date,m.hire_date
        from employees e,employees m
        where m.employee_id=e.manager_id and e.hire_date<m.hire_date;

  Was this answer useful?  Yes



Hi  Rama Srinivas,
 
Can u please explain the query imean ,what is manager_id is it seperate column?

Actually my table has columns like empno,ename,job,sal,comm, hiredate,mgr.

Suppose if the table is like that what is manager_id u was mentioned in the ans.

Can u please clarify my doubt as early as possible.


Thanks,
Swarna.k

  Was this answer useful?  Yes

M.REHMAN

  • May 25th, 2008
 

 select e.employee_id,e.last_name,m.manager_id,
 m.last_name,e.hire_date employee,m.hire_date manager
 from employees e, employees m
 where m.employee_id=e.manager_id
 and e.hire_date < m.hire_date
 

M.REHMAN

  • May 25th, 2008
 

select e.employee_id,e.last_name,m.manager_id, m.last_name,e.hire_date employee,m.hire_date manager from employees e, employees m where m.employee_id=e.manager_id and e.hire_date < m.hire_date

  Was this answer useful?  Yes

Try this

select s.empno, s.ename
from emp s, (select a.empno, a.hiredate from emp a
        where a.empno in (select mgr from emp b
        start with mgr is null connect by prior empno = mgr)) m
where s.mgr = m.empno   
and s.hiredate < m.hiredate;

  Was this answer useful?  Yes

We should use less than operator instead of greater than , given in the previous response


select t.empno,t.hiredate,t.mgr,t1.empno,t1.hiredate
from emp t,emp t1
where t.mgr=t1.empno
and t.hiredate < t1.hiredate

This means that the employee  does not have any manager.

Select e.empno,e.ename From emp e,emp m where m.empno(+)=e.mgrid;

or

Select e.empno,e.ename From emp e left outer join on emp m where m.empno=e.mgrid;

  Was this answer useful?  Yes

  1  select e.employee_id,e.last_name "Employee",m.employee_id "Manager_id",m.last_name "Manager",
  2  e.hire_date "Emp_hiredate",m.hire_date "Manager_Hire_date" from employees e,employees m
  3  where e.manager_id = m.employee_id and e.department_id  = m.department_id
  4* and e.hire_date < m.hire_date
SQL> /

EMPLOYEE_ID Employee                  Manager_id Manager                   Emp_hired Manager_H
----------- ------------------------- ---------- ------------------------- --------- ---------
        144 Vergas                           124 Mourgos                   09-JUL-98 16-NOV-99
        143 Matos                            124 Mourgos                   15-MAR-98 16-NOV-99
        142 Davies                           124 Mourgos                   29-JAN-97 16-NOV-99
        141 Rajs                             124 Mourgos                   17-OCT-95 16-NOV-99
        176 Taylor                           149 Zlotkey                   24-MAR-98 29-JAN-00
        174 Abel                             149 Zlotkey                   11-MAY-96 29-JAN-00

6 rows selected.

  Was this answer useful?  Yes

krishsidd

  • Nov 26th, 2010
 

select e1.*, e2.HIREDATE from emp e1, emp e2
where e1.DEPTNO = e2.DEPTNO and e1.MGR = e2.EMPNO and e1.HIREDATE < e2.HIREDATE

  Was this answer useful?  Yes

There are ways can be accomplished this task for example emp is table having the data jod is date of joining

Method 1:

select * from emp a
where exists (select 1
from emp b
where a.mgrid = b.empno
and trunc(a.jod) < trunc(b.jod)
)

Method 2:

select a1.* from emp a1, emp a2
where a1.mgrid = a2.empno
and trunc(a1.jod) < trunc(a2.jod)

  Was this answer useful?  Yes

Prabakaran

  • Jul 27th, 2011
 

select * from emp as emp1 where emp1.date >= (select date from emp as emp2 where emp1.managerid=emp2.id)

  Was this answer useful?  Yes

janardhan g

  • Aug 7th, 2011
 

select x.ename from emp x,emp y where x.mgr=y.empno and x.hiredate

  Was this answer useful?  Yes

ngoudjou albert

  • May 22nd, 2012
 

We use the selfjoin on the table employees to retrieve the job before thier managers

Code
  1. SELECT * FROM employees e , employees m

  2. WHERE e.manager_id=m.employee_id

  3. AND e.hire_date < m.hire_date;

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions