diff --git a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Customers.sql b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Customers.sql index ffe0e78e..6b3b4799 100644 --- a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Customers.sql +++ b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Customers.sql @@ -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 \ No newline at end of file diff --git a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/SalesOrders.sql b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/SalesOrders.sql index 9a5906c4..6e8826e4 100644 --- a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/SalesOrders.sql +++ b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/SalesOrders.sql @@ -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 - + \ No newline at end of file diff --git a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Suppliers.sql b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Suppliers.sql index 3d2e349d..03ad3a76 100644 --- a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Suppliers.sql +++ b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/Website/Views/Suppliers.sql @@ -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