how to query ?

  • Hello,

    i have a table employee:

    |-----------|--------------|-----------|

    |EmployeeID | EmployeeName | ManagerID |

    |-----------|--------------|-----------|

    |1 | Avery | 0 |

    |2 | Budd | 1 |

    |3 | Crhistine | 1 |

    |4 | Dan | 2 |

    |-----------|--------------|-----------|

    i have a trouble to query that produce such output like this :

    |-------------|------------|

    |EmployeeName | MangerName |

    |-------------|------------|

    |Budd | Avery |

    |Crhistine | Avery |

    |Dan | Budd |

    |-------------|------------|

    please someone help me, i have no idea to query with just one table only

  • Untested, since there's no server handy, but this should do the trick:

    SELECT

        EmployeeName = e.EmployeeName

        ,ManagerName = m.EmployeeName

    FROM

        dbo.Employee AS e

     

        LEFT OUTER JOIN dbo.Employee AS m ON

            e.ManagerID = m.EmployeeID

  • thanks Mr. David, it works, i really appreciate your answer

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

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