SQL Server, SSRS and Crystal Reports
Tuesday, 10 November 2009
Self Join - SQL
Self join between two instances of the same table. For example, obtaining employees and their managers.
SELECT
E.Name
as
emp, M.Name
as
mgr
FROM
Employees
as
E
LEFT OUTER JOIN
Employees
as
M
ON
E.ParentID = M.EmployeeID
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment