16.4k views
5 votes
Write a query that joins the HumanResources.Employee table to the Person.Person table so that you can display the FirstName, LastName, and HireDate columns for each employee. Display the JobTitle along with a count of employees for the title.

1 Answer

4 votes

Final answer:

To join the HumanResources.Employee table to the Person.Person table and display the FirstName, LastName, and HireDate columns for each employee, you can use the provided SQL query. Additionally, to display the JobTitle along with a count of employees for each title, the query can be modified.

Step-by-step explanation:

To join the HumanResources.Employee table to the Person.Person table and display the FirstName, LastName, and HireDate columns for each employee, you can use the following query:


SELECT e.FirstName, e.LastName, e.HireDate
FROM HumanResources.Employee AS e
JOIN Person.Person AS p ON e.BusinessEntityID = p.BusinessEntityID;


To display the JobTitle along with a count of employees for each title, you can modify the query as follows:


SELECT e.FirstName, e.LastName, e.HireDate, j.JobTitle, COUNT(*) AS EmployeeCount
FROM HumanResources.Employee AS e
JOIN Person.Person AS p ON e.BusinessEntityID = p.BusinessEntityID
JOIN HumanResources.EmployeeJobTitle AS j ON e.EmployeeID = j.EmployeeID
GROUP BY e.FirstName, e.LastName, e.HireDate, j.JobTitle;
User Suanmeiguo
by
8.1k points