Results 1 to 2 of 2

Thread: Pls help with a query

  1. #1
    Join Date
    Dec 2008
    Posts
    1

    Pls help with a query

    I hav a table like this

    -----Table 1 :--------

    MangerID EmpID
    15 18
    15 10
    18 60
    18 3084
    60 78
    60 57

    A manager can be a supervisor as well as employee at the same time.I want to create a hierarchy report with the top level manager at the top & subordinates at the bottom.
    I want a result like this :

    Supervisor Sub1 Sub2 Sub3
    15 18 3084 null
    15 18 60 78
    15 18 60 57
    15 10 null null

    Can any1 help me with a query?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Look for "hierarchical queries" in SQL Server books online, it has the query for what you are trying to do.

Tags for this Thread

Posting Permissions

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