HumanResources.vEmployeeDepartmentHistory (view)

From dbscript Online Help
Revision as of 23:56, 28 December 2009 by Bot (talk | contribs)
Jump to: navigation, search

wikibot

view HumanResources.vEmployeeDepartmentHistory
Description Returns employee name and current and previous departments.
CREATE VIEW [HumanResources].[vEmployeeDepartmentHistory] 
AS 
SELECT 
    e.[EmployeeID] 
    ,c.[Title] 
    ,c.[FirstName] 
    ,c.[MiddleName] 
    ,c.[LastName] 
    ,c.[Suffix] 
    ,s.[Name] AS [Shift]
    ,d.[Name] AS [Department] 
    ,d.[GroupName] 
    ,edh.[StartDate] 
    ,edh.[EndDate]
FROM [HumanResources].[Employee] e
    INNER JOIN [Person].[Contact] c 
    ON c.[ContactID] = e.[ContactID]
    INNER JOIN [HumanResources].[EmployeeDepartmentHistory] edh 
    ON e.[EmployeeID] = edh.[EmployeeID] 
    INNER JOIN [HumanResources].[Department] d 
    ON edh.[DepartmentID] = d.[DepartmentID] 
    INNER JOIN [HumanResources].[Shift] s
    ON s.[ShiftID] = edh.[ShiftID];


Dependency Type Object Type Referenced Object
Select Table HumanResources.Department
Select Table HumanResources.Employee
Select Table HumanResources.EmployeeDepartmentHistory
Select Table HumanResources.Shift
Select Table Person.Contact


automatically generated

view HumanResources.vEmployeeDepartmentHistory
Description Returns employee name and current and previous departments.

CREATE VIEW [HumanResources].[vEmployeeDepartmentHistory] 
AS 
SELECT 
    e.[EmployeeID] 
    ,c.[Title] 
    ,c.[FirstName] 
    ,c.[MiddleName] 
    ,c.[LastName] 
    ,c.[Suffix] 
    ,s.[Name] AS [Shift]
    ,d.[Name] AS [Department] 
    ,d.[GroupName] 
    ,edh.[StartDate] 
    ,edh.[EndDate]
FROM [HumanResources].[Employee] e
    INNER JOIN [Person].[Contact] c 
    ON c.[ContactID] = e.[ContactID]
    INNER JOIN [HumanResources].[EmployeeDepartmentHistory] edh 
    ON e.[EmployeeID] = edh.[EmployeeID] 
    INNER JOIN [HumanResources].[Department] d 
    ON edh.[DepartmentID] = d.[DepartmentID] 
    INNER JOIN [HumanResources].[Shift] s
    ON s.[ShiftID] = edh.[ShiftID];


Dependency Type Object Type Referenced Object
Select Table HumanResources.Department
Select Table HumanResources.Employee
Select Table HumanResources.EmployeeDepartmentHistory
Select Table HumanResources.Shift
Select Table Person.Contact
Schema Schema HumanResources