3-level reporting hierarchy.

  • Hi

    I have a requirement where I need to get employees managers up to 3 levels.

    (Example : A(Employee) -> B(Manager 1) -> C(Manager 2))

    Appreciate help.

    Thanks,
    Abhas

  • abhas - Monday, September 4, 2017 9:10 AM

    Hi

    I have a requirement where I need to get employees managers up to 3 levels.

    (Example : A(Employee) -> B(Manager 1) -> C(Manager 2))

    Appreciate help.

    Thanks,
    Abhas

    What do you want for CEO level or people who don't have 3 levels?

    What have you tried so far?  Do you have a test harness of sample data and code you have tried you can share so our code is meaningful to your data.

  • abhas - Monday, September 4, 2017 9:10 AM

    Hi

    I have a requirement where I need to get employees managers up to 3 levels.

    (Example : A(Employee) -> B(Manager 1) -> C(Manager 2))

    Appreciate help.

    Thanks,
    Abhas

    You've given us mostly nothing to go on.  What is the structure of the tables?  What are the keys that uniquely identify the rows?  And why, for goodness sake, have the designers of these tables complicated things by putting them into more than one table instead of an easy to use and maintain single table Adjacency List?

    Please see the first link under "Helpful Links" in my signature line below if you want coded help.  If not, then the answer is to just join the tables on the appropriate keys.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Assuming all employees are in the same table and have a parent_ID field to point up the tree then you are probably looking at a recursive CTE

    You will find loads of examples on these boards and the wider internet

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply