Sales.vSalesPerson
Documentation | AdventureWorks |
Schema | Sales |
Name | vSalesPerson |
Module | Sales |
Sales representiatives (names and addresses) and their sales-related information.
Columns
Key | Name | Data type | Null | Attributes | References | Description | ||
---|---|---|---|---|---|---|---|---|
1 | BusinessEntityID | int | ||||||
2 | Title | nvarchar(8) | ||||||
3 | FirstName | nvarchar(50) | ||||||
4 | MiddleName | nvarchar(50) | ||||||
5 | LastName | nvarchar(50) | ||||||
6 | Suffix | nvarchar(10) | ||||||
7 | JobTitle | nvarchar(50) | ||||||
8 | PhoneNumber | nvarchar(25) | ||||||
9 | PhoneNumberType | nvarchar(50) | ||||||
10 | EmailAddress | nvarchar(50) | ||||||
11 | EmailPromotion | int | ||||||
12 | AddressLine1 | nvarchar(60) | ||||||
13 | AddressLine2 | nvarchar(60) | ||||||
14 | City | nvarchar(30) | ||||||
15 | StateProvinceName | nvarchar(50) | ||||||
16 | PostalCode | nvarchar(15) | ||||||
17 | CountryRegionName | nvarchar(50) | ||||||
18 | TerritoryName | nvarchar(50) | ||||||
19 | TerritoryGroup | nvarchar(50) | ||||||
20 | SalesQuota | money | ||||||
21 | SalesYTD | money | ||||||
22 | SalesLastYear | money |
Uses
Script
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]; |
Exported: 2019-02-04 23:13, Last imported: 2018-03-07 11:56