
Ultimate access to all questions.
You are working as a data engineer for a retail company that uses Microsoft Fabric to manage its data warehouse. The company wants to analyze customer purchase behaviors to tailor marketing strategies. You are tasked with writing a SQL query that retrieves the total purchase amount and the most recent purchase date for each customer from a dataset named 'CustomerPurchases', which includes columns for CustomerID, ProductID, PurchaseDate, and PurchaseAmount. The solution must efficiently handle large volumes of data and provide accurate results for strategic decision-making. Which of the following SQL queries best meets these requirements? (Choose one option)
A
SELECT CustomerID, SUM(PurchaseAmount) AS TotalAmount, MAX(PurchaseDate) AS LastPurchaseDate FROM CustomerPurchases GROUP BY CustomerID;
B
SELECT CustomerID, SUM(PurchaseAmount) AS TotalAmount, MAX(PurchaseDate) AS LastPurchaseDate FROM CustomerPurchases GROUP BY CustomerID ORDER BY TotalAmount DESC;
C
SELECT CustomerID, SUM(PurchaseAmount) AS TotalAmount, MAX(PurchaseDate) AS LastPurchaseDate FROM CustomerPurchases;
D
SELECT CustomerID, SUM(PurchaseAmount) AS TotalAmount, MAX(PurchaseDate) AS LastPurchaseDate FROM CustomerPurchases GROUP BY CustomerID HAVING MAX(PurchaseDate) > DATEADD(month, -1, GETDATE());