I was trying to do a query using the AdventureWorks2012 ,in which the managers and the employees who work under those managers will be separated into two columns.
USE AdventureWorks2012
SELECT
m.JobTitle AS [Manager],e.JobTitle AS [Employees]
FROM
HumanResources.Employee AS m INNER JOIN HumanResources.Employee AS e
ON
m.BusinessEntityID=e.BusinessEntityID
WHERE
m.JobTitle LIKE'%Manager' AND m.JobTitle ='Chief Executive Officer' AND (e.JobTitle NOT LIKE '%Manager' AND m.JobTitle <> 'Chief Executive Officer')
Like, the chief executive officer or the ceo is the head of the so all the employees should first come into the employees column under his suppervision. Then, the Account manager And then all the employees who work under him and so on.
I tried the same query with cross join as well as case expression too. But none of them helped.I hope that you will understand mu question.
So,plzz help.