Which feature should you use?

You have two views named Sales.SalesSummaryOverall and Sales.CustomerAndSalesSummary.
They are defined as follows:
CREATE VIEW Sales.SalesSummaryOverall
AS
SELECT CustomerId, SUM(SalesTotal) AS OverallTotal
FROM Sales.SalesOrder
GROUP BY CustomerId
GO
CREATE VIEW Sales.CustomerAndSalesSummary
AS
SELECT Customer.Name,
SalesSummaryOverall.OverallTotal,
(SELECT AVG(OverallTotal)
FROM Sales.SalesSummaryOverall
WHERE SalesSummaryOverall.CustomerId =
Customer.CustomerId) AS avgOverallTotal,
(SELECT MAX(OverallTotal)
FROM Sales.SalesSummaryOverall
WHERE SalesSummaryOverall.CustomerId =
Customer.CustomerId) AS maxOverallTotal,
FROM Sales.Customer
LEFT OUTER JOIN Sales. Sales.SalesSummaryOverall
ON SalesSummaryByYear.CustomerId = Customer.CustomerId
GO
You have been tasked to modify the Sales.CustomerAndSalesSummary view to remove references to
other views. You need to identify a feature to use in the modified version of the
Sales.CustomerAndSalesSummary object to achieve the task.
Which feature should you use?

You have two views named Sales.SalesSummaryOverall and Sales.CustomerAndSalesSummary.
They are defined as follows:
CREATE VIEW Sales.SalesSummaryOverall
AS
SELECT CustomerId, SUM(SalesTotal) AS OverallTotal
FROM Sales.SalesOrder
GROUP BY CustomerId
GO
CREATE VIEW Sales.CustomerAndSalesSummary
AS
SELECT Customer.Name,
SalesSummaryOverall.OverallTotal,
(SELECT AVG(OverallTotal)
FROM Sales.SalesSummaryOverall
WHERE SalesSummaryOverall.CustomerId =
Customer.CustomerId) AS avgOverallTotal,
(SELECT MAX(OverallTotal)
FROM Sales.SalesSummaryOverall
WHERE SalesSummaryOverall.CustomerId =
Customer.CustomerId) AS maxOverallTotal,
FROM Sales.Customer
LEFT OUTER JOIN Sales. Sales.SalesSummaryOverall
ON SalesSummaryByYear.CustomerId = Customer.CustomerId
GO
You have been tasked to modify the Sales.CustomerAndSalesSummary view to remove references to
other views. You need to identify a feature to use in the modified version of the
Sales.CustomerAndSalesSummary object to achieve the task.
Which feature should you use?

A.
Table variables

B.
Temporary tables

C.
Userdefined
table types

D.
Common table expressions



Leave a Reply 0

Your email address will not be published. Required fields are marked *