sub query

  • hi friends,

    any one call help me with fallowing query

    How to find the name of the employee who manages more employees?

  • sandeep4testing (5/19/2012)


    any one call help me with fallowing query

    How to find the name of the employee who manages more employees?

    Do you realize nobody can write your (home work) query not knowing how many tables are involved and how they look like?

    Many ways to do it, one of them would look like...

    1- Count rows grouping by the this-employee-reports-to column

    2- Get the result set sorted in descending order by the row count

    3- Show the name of the employee - based on this-employee-reports-to column - that shows on top of the result set.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • If you were using SQL Server I would ask you to use Hierarchy column.

    In other ways, if both the employee and the manager details are stored in the same table, do a self join... should be pretty easy if you provide the table structure.

    =======================================================================================

    Visit my technical reference; you might find some of your issues already documented.

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

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