Northwind Database (Document! X Sample)
Sales.vSalesPerson View
AdventureWorks Database > Sales Schema : Sales.vSalesPerson View
Description
Sales representiatives (names and addresses) and their sales-related information.
Properties
Creation Date27/10/2017 14:33
Is Schema Bound
Encrypted
Ansi Nulls
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
  Integer4   
  VarWChar8  
  dbo.Name50   
  dbo.Name50  
  dbo.Name50   
  VarWChar10  
  VarWChar50   
  dbo.Phone25  
  dbo.Name50  
  VarWChar50  
  Integer4   
  VarWChar60   
  VarWChar60  
  VarWChar30   
  dbo.Name50   
  VarWChar15   
  dbo.Name50   
  dbo.Name50  
  VarWChar50  
  Currency8  
  Currency8   
  Currency8   
Objects that Sales.vSalesPerson depends on
 Database ObjectObject TypeDescriptionDep Level
Person.Address tablePerson.AddressTableStreet address information for customers, employees, and vendors.1
Person.AddressType tablePerson.AddressTypeTableTypes of addresses stored in the Address table. 2
Person.BusinessEntity tablePerson.BusinessEntityTableSource of the ID that connects vendors, customers, and employees with address and contact information.2
Person.BusinessEntityAddress tablePerson.BusinessEntityAddressTableCross-reference table mapping customers, vendors, and employees to their addresses.1
Person.CountryRegion tablePerson.CountryRegionTableLookup table containing the ISO standard codes for countries and regions.1
Person.EmailAddress tablePerson.EmailAddressTableWhere to send a person email.1
HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.1
dbo.Flag datatypedbo.FlagUser Defined Data Type 2
dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 2
Person.Person tablePerson.PersonTableHuman beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.1
Person.PersonPhone tablePerson.PersonPhoneTableTelephone number and type of a person.1
dbo.Phone datatypedbo.PhoneUser Defined Data Type 2
Person.PhoneNumberType tablePerson.PhoneNumberTypeTableType of phone number of a person.1
Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.1
Sales.SalesTerritory tableSales.SalesTerritoryTableSales territory lookup table.1
Person.StateProvince tablePerson.StateProvinceTableState and province lookup table.1
View Definition
CREATE VIEW [Sales].[vSalesPerson] 
AS 

SELECT 
    s.[BusinessEntityID]
    ,p.[Title]
    ,p.[FirstName]
    ,p.[MiddleName]
    ,p.[LastName]
    ,p.[Suffix]
    ,e.[JobTitle]
    ,pp.[PhoneNumber]
    ,pnt.[Name] AS [PhoneNumberType]
    ,ea.[EmailAddress]
    ,p.[EmailPromotion]
    ,a.[AddressLine1]
    ,a.[AddressLine2]
    ,a.[City]
    ,[StateProvinceName] = sp.[Name]
    ,a.[PostalCode]
    ,[CountryRegionName] = cr.[Name]
    ,[TerritoryName] = st.[Name]
    ,[TerritoryGroup] = st.[Group]
    ,s.[SalesQuota]
    ,s.[SalesYTD]
    ,s.[SalesLastYear]
FROM [Sales].[SalesPerson] s
    INNER JOIN [HumanResources].[Employee] e 
    ON e.[BusinessEntityID] = s.[BusinessEntityID]
    INNER JOIN [Person].[Person] p
    ON p.[BusinessEntityID] = s.[BusinessEntityID]
    INNER JOIN [Person].[BusinessEntityAddress] bea 
    ON bea.[BusinessEntityID] = s.[BusinessEntityID] 
    INNER JOIN [Person].[Address] a 
    ON a.[AddressID] = bea.[AddressID]
    INNER JOIN [Person].[StateProvince] sp 
    ON sp.[StateProvinceID] = a.[StateProvinceID]
    INNER JOIN [Person].[CountryRegion] cr 
    ON cr.[CountryRegionCode] = sp.[CountryRegionCode]
    LEFT OUTER JOIN [Sales].[SalesTerritory] st 
    ON st.[TerritoryID] = s.[TerritoryID]
    LEFT OUTER JOIN [Person].[EmailAddress] ea
    ON ea.[BusinessEntityID] = p.[BusinessEntityID]
    LEFT OUTER JOIN [Person].[PersonPhone] pp
    ON pp.[BusinessEntityID] = p.[BusinessEntityID]
    LEFT OUTER JOIN [Person].[PhoneNumberType] pnt
    ON pnt.[PhoneNumberTypeID] = pp.[PhoneNumberTypeID];
See Also

Related Objects

Sales Schema
AdventureWorks Database