Welcome Guest, you are in: Login

devio dbscript ScrewTurn Wiki

RSS RSS

Navigation





Search the wiki
»

PoweredBy

wikibot

ViewHumanResources.vEmployeeDepartmentHistory
DescriptionReturns employee name and current and previous departments.

Source

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];

References

Dependency TypeObject TypeReferenced Object
SelectTableHumanResources.Department
SelectTableHumanResources.Employee
SelectTableHumanResources.EmployeeDepartmentHistory
SelectTableHumanResources.Shift
SelectTablePerson.Contact
SchemaSchemaHumanResources

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam.