Employee Manager Report - Sql Server

后端 未结 4 1331
借酒劲吻你
借酒劲吻你 2021-01-28 21:14

I have the below table

empid   empname     managerID
1          A          NULL
2          B           1
3          C           1
4          D           2
         


        
4条回答
  •  渐次进展
    2021-01-28 21:22

    I think, your solution is most appropriate, but we can rewrite it, e.g.:

    select t1.empname [EmpName]
        , (select t2.empname from @t t2 where t2.empid = t1.managerID) [ManagerName]
    from @t t1
    

提交回复
热议问题