I have 2 tables in sql server: Employee (Job Title, Hire Date)
- Person (FirstName, LastName) And I need to return the E.JobTitle, E.HireDate,P.FirstName ,P.LastName along with the how many employees have the same job title.
so I used this query:
SELECT E.JobTitle,
E.HireDate,
P.FirstName,
P.LastName,
COUNT(E.JobTitle)
FROM AdventureWorks2019.HumanResources.Employee E
JOIN AdventureWorks2019.Person.Person P ON E.BusinessEntityID = P.BusinessEntityID
GROUP BY E.JobTitle,
E.HireDate,
P.FirstName,
P.LastName;
the problem is that the query returns 1 per the count, while I'd expect to get per each row the count of the num employees with that job title. my question is how can I get the correct count?