Question: 4. Rewrite the following derived table in CTE(7 points). --The following is a derived table (Subquery) Use Adventure Works 2012; SELECT Orders. CustomerID, SalesOrderID, Order

4. Rewrite the following derived table in CTE(7 points). --The following is a derived table (Subquery) Use Adventure Works 2012; SELECT Orders. CustomerID, SalesOrderID, Order Date, TotalDue, CustTotal, AvgSale, MinSale FROM Sales Sales OrderHeader AS Orders JOIN SELECT SUM(TotalDue) AS CustTotal, AVG(TotalDue AS AvgSale, MIN(TotalDue) AS MinSale, MAX(TotalDue AS MaxSale, CustomerID FROM Sales Sales OrderHeader GROUP BY CustomerID) AS Sales ON Orders. CustomerID = Sales. CustomerID -- 31465 records --Re-write the above derived table as a CTE
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
