mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Updated WWI Website views
This commit is contained in:
+12
-6
@@ -8,13 +8,17 @@ SELECT s.CustomerID,
|
||||
ap.FullName AS AlternateContact,
|
||||
s.PhoneNumber,
|
||||
s.FaxNumber,
|
||||
bg.BuyingGroupName,
|
||||
s.WebsiteURL,
|
||||
dm.DeliveryMethodName AS DeliveryMethod,
|
||||
c.CityName AS CityName,
|
||||
s.DeliveryLocation AS DeliveryLocation,
|
||||
s.DeliveryRun,
|
||||
s.RunPosition
|
||||
bg.BuyingGroupName,
|
||||
DeliveryLocation = JSON_QUERY((SELECT
|
||||
type = 'Feature',
|
||||
[geometry.type] = 'Point',
|
||||
[geometry.coordinates] = JSON_QUERY(CONCAT('[',s.DeliveryLocation.Long,',',s.DeliveryLocation.Lat ,']')),
|
||||
[properties.DeliveryMethod] = DeliveryMethodName,
|
||||
[properties.CityName] = c.CityName,
|
||||
[properties.Province] = sp.StateProvinceName,
|
||||
[properties.Territory] = sp.SalesTerritory
|
||||
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER))
|
||||
FROM Sales.Customers AS s
|
||||
LEFT OUTER JOIN Sales.CustomerCategories AS sc
|
||||
ON s.CustomerCategoryID = sc.CustomerCategoryID
|
||||
@@ -28,3 +32,5 @@ LEFT OUTER JOIN [Application].DeliveryMethods AS dm
|
||||
ON s.DeliveryMethodID = dm.DeliveryMethodID
|
||||
LEFT OUTER JOIN [Application].Cities AS c
|
||||
ON s.DeliveryCityID = c.CityID
|
||||
LEFT OUTER JOIN [Application].StateProvinces AS sp
|
||||
ON sp.StateProvinceID = c.StateProvinceID
|
||||
+15
-4
@@ -1,14 +1,25 @@
|
||||
|
||||
CREATE VIEW Website.SalesOrders
|
||||
AS
|
||||
SELECT o.OrderID, o.OrderDate, OrderNumber = o.CustomerPurchaseOrderNumber, o.ExpectedDeliveryDate,
|
||||
o.PickingCompletedWhen, o.DeliveryInstructions,
|
||||
SELECT o.OrderID, o.OrderDate, OrderNumber = o.CustomerPurchaseOrderNumber,
|
||||
o.ExpectedDeliveryDate, o.PickingCompletedWhen,
|
||||
o.CustomerID, c.CustomerName, c.PhoneNumber, c.FaxNumber, c.WebsiteURL,
|
||||
c.DeliveryAddressLine1, c.DeliveryAddressLine2, c.DeliveryPostalCode, c.DeliveryLocation,
|
||||
DeliveryLocation = JSON_QUERY((SELECT
|
||||
[type] = 'Feature',
|
||||
[geometry.type] = 'Point',
|
||||
[geometry.coordinates] = JSON_QUERY(CONCAT('[',c.DeliveryLocation.Long,',',c.DeliveryLocation.Lat ,']')),
|
||||
[properties.DeliveryMethod] = dm.DeliveryMethodName,
|
||||
[properties.AddressLine1] = c.DeliveryAddressLine1,
|
||||
[properties.AddressLine2] = c.DeliveryAddressLine2,
|
||||
[properties.PostalCode] = c.DeliveryPostalCode,
|
||||
[properties.Instructions] = o.DeliveryInstructions
|
||||
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER)),
|
||||
SalesPerson = sp.FullName, SalesPersonPhone = sp.PhoneNumber, SalesPersonEmail = sp.EmailAddress
|
||||
FROM Sales.Orders o
|
||||
INNER JOIN Sales.Customers c
|
||||
ON o.CustomerID = c.CustomerID
|
||||
LEFT OUTER JOIN [Application].DeliveryMethods AS dm
|
||||
ON c.DeliveryMethodID = dm.DeliveryMethodID
|
||||
INNER JOIN Application.People sp
|
||||
ON o.SalespersonPersonID = sp.PersonID
|
||||
|
||||
|
||||
+22
-14
@@ -9,18 +9,26 @@ SELECT s.SupplierID,
|
||||
s.PhoneNumber,
|
||||
s.FaxNumber,
|
||||
s.WebsiteURL,
|
||||
dm.DeliveryMethodName AS DeliveryMethod,
|
||||
c.CityName AS CityName,
|
||||
s.DeliveryLocation AS DeliveryLocation,
|
||||
s.SupplierReference
|
||||
s.SupplierReference,
|
||||
DeliveryLocation = JSON_QUERY((SELECT
|
||||
[type] = 'Feature',
|
||||
[geometry.type] = 'Point',
|
||||
[geometry.coordinates] = JSON_QUERY(CONCAT('[',s.DeliveryLocation.Long,',',s.DeliveryLocation.Lat ,']')),
|
||||
[properties.DeliveryMethod] = dm.DeliveryMethodName,
|
||||
[properties.City] = c.CityName,
|
||||
[properties.Province] = sp.StateProvinceName,
|
||||
[properties.Territory] = sp.SalesTerritory
|
||||
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER))
|
||||
FROM Purchasing.Suppliers AS s
|
||||
LEFT OUTER JOIN Purchasing.SupplierCategories AS sc
|
||||
ON s.SupplierCategoryID = sc.SupplierCategoryID
|
||||
LEFT OUTER JOIN [Application].People AS pp
|
||||
ON s.PrimaryContactPersonID = pp.PersonID
|
||||
LEFT OUTER JOIN [Application].People AS ap
|
||||
ON s.AlternateContactPersonID = ap.PersonID
|
||||
LEFT OUTER JOIN [Application].DeliveryMethods AS dm
|
||||
ON s.DeliveryMethodID = dm.DeliveryMethodID
|
||||
LEFT OUTER JOIN [Application].Cities AS c
|
||||
ON s.DeliveryCityID = c.CityID
|
||||
LEFT OUTER JOIN Purchasing.SupplierCategories AS sc
|
||||
ON s.SupplierCategoryID = sc.SupplierCategoryID
|
||||
LEFT OUTER JOIN [Application].People AS pp
|
||||
ON s.PrimaryContactPersonID = pp.PersonID
|
||||
LEFT OUTER JOIN [Application].People AS ap
|
||||
ON s.AlternateContactPersonID = ap.PersonID
|
||||
LEFT OUTER JOIN [Application].DeliveryMethods AS dm
|
||||
ON s.DeliveryMethodID = dm.DeliveryMethodID
|
||||
LEFT OUTER JOIN [Application].Cities AS c
|
||||
ON s.DeliveryCityID = c.CityID
|
||||
LEFT OUTER JOIN [Application].StateProvinces AS sp
|
||||
ON sp.StateProvinceID = c.StateProvinceID
|
||||
|
||||
Reference in New Issue
Block a user