Difference between revisions of "Sales.vStoreWithDemographics (view)"
(One intermediate revision by the same user not shown) | |||
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 |
| Sales.vStoreWithDemographics | | Sales.vStoreWithDemographics | ||
|- valign="top" | |- valign="top" | ||
| '''Description | | '''Description | ||
| Stores (names and addresses) that sell Adventure Works Cycles products to consumers. | | Stores (names and addresses) that sell Adventure Works Cycles products to consumers. | ||
− | |||
|} | |} | ||
+ | === Source === | ||
<pre> | <pre> | ||
CREATE VIEW [Sales].[vStoreWithDemographics] AS | CREATE VIEW [Sales].[vStoreWithDemographics] AS | ||
Line 73: | Line 73: | ||
</pre> | </pre> | ||
− | + | === References === | |
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | {| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse" | ||
|- style="background:silver" | |- style="background:silver" | ||
Line 80: | Line 80: | ||
| '''Referenced Object | | '''Referenced Object | ||
− | |- | + | |- valign="top" |
| Select | | Select | ||
| Table | | Table | ||
| [[Person.Address_(table)|Person.Address]] | | [[Person.Address_(table)|Person.Address]] | ||
− | |- | + | |- valign="top" |
| Select | | Select | ||
| Table | | Table | ||
| [[Person.AddressType_(table)|Person.AddressType]] | | [[Person.AddressType_(table)|Person.AddressType]] | ||
− | |- | + | |- valign="top" |
| Select | | Select | ||
| Table | | Table | ||
| [[Person.Contact_(table)|Person.Contact]] | | [[Person.Contact_(table)|Person.Contact]] | ||
− | |- | + | |- valign="top" |
| Select | | Select | ||
| Table | | Table | ||
| [[Person.ContactType_(table)|Person.ContactType]] | | [[Person.ContactType_(table)|Person.ContactType]] | ||
− | |- | + | |- 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.Customer_(table)|Sales.Customer]] | | [[Sales.Customer_(table)|Sales.Customer]] | ||
− | |- | + | |- valign="top" |
| Select | | Select | ||
| Table | | Table | ||
| [[Sales.CustomerAddress_(table)|Sales.CustomerAddress]] | | [[Sales.CustomerAddress_(table)|Sales.CustomerAddress]] | ||
− | |- | + | |- valign="top" |
| Select | | Select | ||
| Table | | Table | ||
| [[Sales.Store_(table)|Sales.Store]] | | [[Sales.Store_(table)|Sales.Store]] | ||
− | |- | + | |- valign="top" |
| Select | | Select | ||
| Table | | Table | ||
| [[Sales.StoreContact_(table)|Sales.StoreContact]] | | [[Sales.StoreContact_(table)|Sales.StoreContact]] | ||
+ | |||
+ | |- valign="top" | ||
+ | | Schema | ||
+ | | Schema | ||
+ | | [[Sales_(schema)|Sales]] | ||
|} | |} | ||
− | |||
Latest revision as of 23:18, 23 June 2010
wikibot[edit]
View | Sales.vStoreWithDemographics |
Description | Stores (names and addresses) that sell Adventure Works Cycles products to consumers. |
Source[edit]
CREATE VIEW [Sales].[vStoreWithDemographics] AS SELECT s.[CustomerID] ,s.[Name] ,ct.[Name] AS [ContactType] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,c.[Phone] ,c.[EmailAddress] ,c.[EmailPromotion] ,at.[Name] AS [AddressType] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,sp.[Name] AS [StateProvinceName] ,a.[PostalCode] ,cr.[Name] AS [CountryRegionName] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/AnnualSales)[1]', 'money') AS [AnnualSales] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/AnnualRevenue)[1]', 'money') AS [AnnualRevenue] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/BankName)[1]', 'nvarchar(50)') AS [BankName] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/BusinessType)[1]', 'nvarchar(5)') AS [BusinessType] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/YearOpened)[1]', 'integer') AS [YearOpened] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/Specialty)[1]', 'nvarchar(50)') AS [Specialty] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/SquareFeet)[1]', 'integer') AS [SquareFeet] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/Brands)[1]', 'nvarchar(30)') AS [Brands] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/Internet)[1]', 'nvarchar(30)') AS [Internet] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/NumberEmployees)[1]', 'integer') AS [NumberEmployees] FROM [Sales].[Store] s INNER JOIN [Sales].[StoreContact] sc ON sc.[CustomerID] = s.[CustomerID] INNER JOIN [Person].[Contact] c ON c.[ContactID] = sc.[ContactID] INNER JOIN [Person].[ContactType] ct ON sc.[ContactTypeID] = ct.[ContactTypeID] INNER JOIN [Sales].[CustomerAddress] ca ON ca.[CustomerID] = s.[CustomerID] INNER JOIN [Person].[Address] a ON a.[AddressID] = ca.[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 ca.[AddressTypeID] = at.[AddressTypeID] WHERE s.[CustomerID] IN (SELECT [Sales].[Customer].[CustomerID] FROM [Sales].[Customer] WHERE UPPER([Sales].[Customer].[CustomerType]) = 'S');
References[edit]
Dependency Type | Object Type | Referenced Object |
Select | Table | Person.Address |
Select | Table | Person.AddressType |
Select | Table | Person.Contact |
Select | Table | Person.ContactType |
Select | Table | Person.CountryRegion |
Select | Table | Person.StateProvince |
Select | Table | Sales.Customer |
Select | Table | Sales.CustomerAddress |
Select | Table | Sales.Store |
Select | Table | Sales.StoreContact |
Schema | Schema | Sales |
automatically generated[edit]
view | Sales.vStoreWithDemographics |
Description | Stores (names and addresses) that sell Adventure Works Cycles products to consumers. |
CREATE VIEW [Sales].[vStoreWithDemographics] AS SELECT s.[CustomerID] ,s.[Name] ,ct.[Name] AS [ContactType] ,c.[Title] ,c.[FirstName] ,c.[MiddleName] ,c.[LastName] ,c.[Suffix] ,c.[Phone] ,c.[EmailAddress] ,c.[EmailPromotion] ,at.[Name] AS [AddressType] ,a.[AddressLine1] ,a.[AddressLine2] ,a.[City] ,sp.[Name] AS [StateProvinceName] ,a.[PostalCode] ,cr.[Name] AS [CountryRegionName] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/AnnualSales)[1]', 'money') AS [AnnualSales] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/AnnualRevenue)[1]', 'money') AS [AnnualRevenue] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/BankName)[1]', 'nvarchar(50)') AS [BankName] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/BusinessType)[1]', 'nvarchar(5)') AS [BusinessType] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/YearOpened)[1]', 'integer') AS [YearOpened] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/Specialty)[1]', 'nvarchar(50)') AS [Specialty] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/SquareFeet)[1]', 'integer') AS [SquareFeet] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/Brands)[1]', 'nvarchar(30)') AS [Brands] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/Internet)[1]', 'nvarchar(30)') AS [Internet] ,s.[Demographics].value('declare default element namespace "http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"; (/StoreSurvey/NumberEmployees)[1]', 'integer') AS [NumberEmployees] FROM [Sales].[Store] s INNER JOIN [Sales].[StoreContact] sc ON sc.[CustomerID] = s.[CustomerID] INNER JOIN [Person].[Contact] c ON c.[ContactID] = sc.[ContactID] INNER JOIN [Person].[ContactType] ct ON sc.[ContactTypeID] = ct.[ContactTypeID] INNER JOIN [Sales].[CustomerAddress] ca ON ca.[CustomerID] = s.[CustomerID] INNER JOIN [Person].[Address] a ON a.[AddressID] = ca.[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 ca.[AddressTypeID] = at.[AddressTypeID] WHERE s.[CustomerID] IN (SELECT [Sales].[Customer].[CustomerID] FROM [Sales].[Customer] WHERE UPPER([Sales].[Customer].[CustomerType]) = 'S');
Dependency Type | Object Type | Referenced Object |
Select | Table | Person.Address |
Select | Table | Person.AddressType |
Select | Table | Person.Contact |
Select | Table | Person.ContactType |
Select | Table | Person.CountryRegion |
Select | Table | Person.StateProvince |
Select | Table | Sales.Customer |
Select | Table | Sales.CustomerAddress |
Select | Table | Sales.Store |
Select | Table | Sales.StoreContact |
Schema | Schema | Sales |