Results 1 to 3 of 3

Thread: qry

  1. #1
    Join Date
    Oct 2002
    Posts
    36

    Unanswered: qry

    how to retrieve under which manger the employees are working
    That is the hierarchy

  2. #2
    Join Date
    Oct 2002
    Posts
    1

    Self join

    Hi
    I guess you will need to use self join but I cannot say anything for sure because the table structure or design is unknown

    Burzin

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: qry

    Originally posted by vadlamanibujji
    how to retrieve under which manger the employees are working
    That is the hierarchy
    Hierarchical queries are done using the CONNECT BY clause, e.g. to show employee 1 and all his/her subordinates:

    SELECT emp.*
    FROM emp
    CONNECT BY PRIOR empno = mngr_empno
    START WITH empno = 1;

    You can indent rows to show the hierarcy better using the LEVEL pseudocolumn:

    SELECT RPAD( ' ', level, ' ' ) || emp.empname
    FROM emp
    CONNECT BY PRIOR empno = mngr_empno
    START WITH empno = 1;

    By the way, it would be helpful if you were more specific in your Subject lines. Rather than just put "qry" or "question" put something like "hierarchy query" or "TNS Names problem". That way people will know whether it's relevant to them or not!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •