
Ultimate access to all questions.
You are working with a data warehouse in Fabric that contains a table named 'Orders' with columns 'OrderID', 'CustomerID', 'OrderDate', and 'TotalAmount'. You need to write a SQL query to find the top 5 customers who have spent the most in the last year. How would you structure this query?
A
SELECT TOP 5 CustomerID, SUM(TotalAmount) AS TotalSpent FROM Orders WHERE OrderDate >= DATEADD(year, -1, GETDATE()) GROUP BY CustomerID ORDER BY TotalSpent DESC;
B
SELECT CustomerID, SUM(TotalAmount) AS TotalSpent FROM Orders WHERE OrderDate >= DATEADD(year, -1, GETDATE()) GROUP BY CustomerID ORDER BY TotalSpent DESC;
C
SELECT TOP 5 CustomerID, SUM(TotalAmount) AS TotalSpent FROM Orders GROUP BY CustomerID ORDER BY TotalSpent DESC;
D
SELECT CustomerID, SUM(TotalAmount) AS TotalSpent FROM Orders GROUP BY CustomerID ORDER BY TotalSpent DESC;