Sales.vIndividualCustomer
Documentation | AdventureWorks |
Schema | Sales |
Name | vIndividualCustomer |
Module | Sales |
Individual customers (names and addresses) that purchase Adventure Works Cycles products online.
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 | PhoneNumber | nvarchar(25) | ||||||
8 | PhoneNumberType | nvarchar(50) | ||||||
9 | EmailAddress | nvarchar(50) | ||||||
10 | EmailPromotion | int | ||||||
11 | AddressType | nvarchar(50) | ||||||
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 | Demographics | xml |
Uses
Script
CREATE VIEW [Sales].[vIndividualCustomer] AS SELECT p.[BusinessEntityID] ,p.[Title] ,p.[FirstName] ,p.[MiddleName] ,p.[LastName] ,p.[Suffix] ,pp.[PhoneNumber] ,pnt.[Name] AS [PhoneNumberType] ,ea.[EmailAddress] ,p.[EmailPromotion] ,at.[Name] AS [AddressType] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,[StateProvinceName] = sp.[Name] ,a.[PostalCode] ,[CountryRegionName] = cr.[Name] ,p.[Demographics] FROM [Person].[Person] p INNER JOIN [Person].[BusinessEntityAddress] bea ON bea.[BusinessEntityID] = p.[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] INNER JOIN [Person].[AddressType] at ON at.[AddressTypeID] = bea.[AddressTypeID] INNER JOIN [Sales].[Customer] c ON c.[PersonID] = p.[BusinessEntityID] 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] WHERE c.StoreID IS NULL; |
Exported: 2019-02-04 23:13, Last imported: 2018-03-07 11:56