
Answer-first summary for fast verification
Answer: SELECT CustomerName, EmailAddress, SUM(PurchaseAmount) AS TotalPurchase FROM CustomerData GROUP BY CustomerName, EmailAddress ORDER BY TotalPurchase DESC LIMIT 10;
Option D is the correct choice because it accurately calculates the total purchase amount for each customer using the SUM() function, groups the results by customer name and email address, and orders the results in descending order of total purchase to identify the top spenders. The LIMIT 10 clause efficiently retrieves only the top 10 customers, making the query scalable and compliant with data privacy regulations by limiting data exposure. This approach is optimal for targeting high-value customers in marketing campaigns.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You are working as a Fabric Analytics Engineer and are tasked with optimizing a SQL query for a large dataset in a Fabric warehouse. The dataset contains detailed customer information, including names, email addresses, and purchase history. Your goal is to identify the top 10 customers based on their total purchase amounts, including their names and email addresses, to target them for a high-value marketing campaign. The solution must be efficient, scalable, and comply with data privacy regulations. Which of the following SQL queries best meets these requirements? (Choose one option)
A
SELECT TOP 10 CustomerName, EmailAddress, SUM(PurchaseAmount) AS TotalPurchase FROM CustomerData GROUP BY CustomerName, EmailAddress ORDER BY TotalPurchase DESC;
B
SELECT CustomerName, EmailAddress, MAX(PurchaseAmount) AS TotalPurchase FROM CustomerData GROUP BY CustomerName, EmailAddress ORDER BY TotalPurchase DESC LIMIT 10;
C
SELECT CustomerName, EmailAddress, AVG(PurchaseAmount) AS TotalPurchase FROM CustomerData GROUP BY CustomerName, EmailAddress ORDER BY TotalPurchase DESC FETCH FIRST 10 ROWS ONLY;
D
SELECT CustomerName, EmailAddress, SUM(PurchaseAmount) AS TotalPurchase FROM CustomerData GROUP BY CustomerName, EmailAddress ORDER BY TotalPurchase DESC LIMIT 10;