Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trouble with SQL query problem

Author  Topic 

shiarua
Starting Member

2 Posts

Posted - 2006-11-13 : 14:02:52
Employee
EMPLOYEE_ID LAST_NAME FIRST_NAME MI JOB_ID MANAGER_ID HIRE_DATE SALARY COMMISION DEPARTMENT_ID PHONE_NUMBER

Job
JOB_ID FUNCTION JOB_TYPE
Department
DEPARTMENT_ID NAME LOCATION_ID
Location
LOCATION_ID REGIONAL_GROUP
Here are the different tables in my database and Im trying to get a list of all the managers last names with the last names of the people that the manager manages. FUNCTION describes who is a manager and who has other positions. You can link the two tables together with Job_ID.

Im stuck on this, Im a noob at SQL. Please help

Kristen
Test

22859 Posts

Posted - 2006-11-13 : 15:18:47
[code]
SELECT [Employee] = stE.LAST_NAME,
[Manager] = stM.LAST_NAME
FROM Employee AS stE
JOIN Employee AS stM
ON stM.EMPLOYEE_ID = stE.MANAGER_ID
JOIN Job AS stJ
ON stJ.JOB_ID = stE.JOB_ID
AND stJ.FUNCTION = 'MANAGER'
ORDER BY stE.LAST_NAME, stM.LAST_NAME, stE.EMPLOYEE_ID
[/code]
Kristen
Go to Top of Page

shiarua
Starting Member

2 Posts

Posted - 2006-11-14 : 09:41:19
Thank you very much for the help
Go to Top of Page
   

- Advertisement -