Difference between revisions of "Sales.vSalesPerson (view)"

From dbscript Online Help
Jump to: navigation, search
 
Line 2: Line 2:
  
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
|-
+
|- valign="top"
 
| '''View
 
| '''View
 
| Sales.vSalesPerson
 
| Sales.vSalesPerson
Line 8: Line 8:
 
| '''Description
 
| '''Description
 
| Sales representiatives (names and addresses) and their sales-related information.
 
| Sales representiatives (names and addresses) and their sales-related information.
|-
 
 
|}
 
|}
 
  
 
=== Source ===
 
=== Source ===
Line 62: Line 60:
 
| '''Referenced Object
 
| '''Referenced Object
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[HumanResources.Employee_(table)|HumanResources.Employee]]
 
| [[HumanResources.Employee_(table)|HumanResources.Employee]]
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[HumanResources.EmployeeAddress_(table)|HumanResources.EmployeeAddress]]
 
| [[HumanResources.EmployeeAddress_(table)|HumanResources.EmployeeAddress]]
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[Person.Address_(table)|Person.Address]]
 
| [[Person.Address_(table)|Person.Address]]
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[Person.Contact_(table)|Person.Contact]]
 
| [[Person.Contact_(table)|Person.Contact]]
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[Person.CountryRegion_(table)|Person.CountryRegion]]
 
| [[Person.CountryRegion_(table)|Person.CountryRegion]]
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[Person.StateProvince_(table)|Person.StateProvince]]
 
| [[Person.StateProvince_(table)|Person.StateProvince]]
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[Sales.SalesPerson_(table)|Sales.SalesPerson]]
 
| [[Sales.SalesPerson_(table)|Sales.SalesPerson]]
  
|-
+
|- valign="top"
 
| Select
 
| Select
 
| Table
 
| Table
 
| [[Sales.SalesTerritory_(table)|Sales.SalesTerritory]]
 
| [[Sales.SalesTerritory_(table)|Sales.SalesTerritory]]
  
|-
+
|- valign="top"
 
| Schema
 
| Schema
 
| Schema
 
| Schema

Latest revision as of 00:18, 24 June 2010

wikibot[edit]

View Sales.vSalesPerson
Description Sales representiatives (names and addresses) and their sales-related information.

Source[edit]

CREATE VIEW [Sales].[vSalesPerson] 
AS 
SELECT 
    s.[SalesPersonID]
    ,c.[Title]
    ,c.[FirstName]
    ,c.[MiddleName]
    ,c.[LastName]
    ,c.[Suffix]
    ,[JobTitle] = e.[Title]
    ,c.[Phone]
    ,c.[EmailAddress]
    ,c.[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.[EmployeeID] = s.[SalesPersonID]
    LEFT OUTER JOIN [Sales].[SalesTerritory] st 
    ON st.[TerritoryID] = s.[TerritoryID]
    INNER JOIN [Person].[Contact] c 
    ON c.[ContactID] = e.[ContactID]
    INNER JOIN [HumanResources].[EmployeeAddress] ea 
    ON e.[EmployeeID] = ea.[EmployeeID] 
    INNER JOIN [Person].[Address] a 
    ON ea.[AddressID] = a.[AddressID]
    INNER JOIN [Person].[StateProvince] sp 
    ON sp.[StateProvinceID] = a.[StateProvinceID]
    INNER JOIN [Person].[CountryRegion] cr 
    ON cr.[CountryRegionCode] = sp.[CountryRegionCode];

References[edit]

Dependency Type Object Type Referenced Object
Select Table HumanResources.Employee
Select Table HumanResources.EmployeeAddress
Select Table Person.Address
Select Table Person.Contact
Select Table Person.CountryRegion
Select Table Person.StateProvince
Select Table Sales.SalesPerson
Select Table Sales.SalesTerritory
Schema Schema Sales


automatically generated[edit]

view Sales.vSalesPerson
Description Sales representiatives (names and addresses) and their sales-related information.

CREATE VIEW [Sales].[vSalesPerson] 
AS 
SELECT 
    s.[SalesPersonID]
    ,c.[Title]
    ,c.[FirstName]
    ,c.[MiddleName]
    ,c.[LastName]
    ,c.[Suffix]
    ,[JobTitle] = e.[Title]
    ,c.[Phone]
    ,c.[EmailAddress]
    ,c.[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.[EmployeeID] = s.[SalesPersonID]
    LEFT OUTER JOIN [Sales].[SalesTerritory] st 
    ON st.[TerritoryID] = s.[TerritoryID]
    INNER JOIN [Person].[Contact] c 
    ON c.[ContactID] = e.[ContactID]
    INNER JOIN [HumanResources].[EmployeeAddress] ea 
    ON e.[EmployeeID] = ea.[EmployeeID] 
    INNER JOIN [Person].[Address] a 
    ON ea.[AddressID] = a.[AddressID]
    INNER JOIN [Person].[StateProvince] sp 
    ON sp.[StateProvinceID] = a.[StateProvinceID]
    INNER JOIN [Person].[CountryRegion] cr 
    ON cr.[CountryRegionCode] = sp.[CountryRegionCode];


Dependency Type Object Type Referenced Object
Select Table HumanResources.Employee
Select Table HumanResources.EmployeeAddress
Select Table Person.Address
Select Table Person.Contact
Select Table Person.CountryRegion
Select Table Person.StateProvince
Select Table Sales.SalesPerson
Select Table Sales.SalesTerritory
Schema Schema Sales