Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created January 27, 2016 09:07
Show Gist options
  • Select an option

  • Save dnasca/48d771a7573b8bb4e774 to your computer and use it in GitHub Desktop.

Select an option

Save dnasca/48d771a7573b8bb4e774 to your computer and use it in GitHub Desktop.
Self Joins - joining a data source to itself
SELECT
e.BusinessEntityId,
e.HireDate,
e.ManagerId,
m.HireDate
FROM
HumanResources.Employee AS e
LEFT OUTER JOIN
HumanResources.Employee AS m
ON
e.ManagerId = m.BusinessEntityId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment