sql - Display all managers and employees without a manager -


i have table in sql server 2008 explanation purposes contains, id, employee , managerid.

eg:

id  employee  managerid 1          null 2   b        2 3   c        2 

i want write query returns non related managerid's , id's managerid equal id.

the result should this,

id  employee    managerid 1             null 2   b           2 

in essence no managers can managers of managers.

at first thought simple using self join , exclude sql statement cannot work. prefer not use exclude statement actual table has more columns , related data return.

if help, grateful.

select employee, managerid your_table managerid null  or managerid = id 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -