How to write this SQL? List employee name, manager name, and employee rank. RRS feed

  • Question

  • In one of the interviews I was asked the following question, which I could not resolve. I was wondering  if you could help me with it?

    Question 1:

    Employee Table

    RecId int identity primary key

    Name varchar(50) not null

    ManagerId int null (Refereces to Employee.RecId)

    Question – Write a SQL query to produce the following output

    Employee Name, Manager Name, Rank

    Note on Rank: Rank indicated employees organizational Rank e.g. CEO is 1, as all reports into CEO, 2 could be other C-class officers like CTO, CFO, then 3 VP reporting into C-Class officers.

    Thursday, May 10, 2012 12:29 AM