
Ultimate access to all questions.
Consider a scenario where you are tasked with querying a lakehouse in Fabric to extract sales data for the last quarter. The lakehouse contains multiple tables, including 'Sales', 'Products', and 'Customers'. Write a SQL query that joins these tables to retrieve the total sales amount, product name, and customer name for each transaction. Additionally, ensure that the query filters out any transactions that occurred before the last quarter. How would you structure this query?
A
SELECT SUM(Sales.Amount) AS TotalSales, Products.Name AS ProductName, Customers.Name AS CustomerName FROM Sales JOIN Products ON Sales.ProductID = Products.ID JOIN Customers ON Sales.CustomerID = Customers.ID WHERE Sales.Date >= DATEADD(quarter, -1, GETDATE()) GROUP BY Products.Name, Customers.Name;
B
SELECT Sales.Amount AS TotalSales, Products.Name AS ProductName, Customers.Name AS CustomerName FROM Sales JOIN Products ON Sales.ProductID = Products.ID JOIN Customers ON Sales.CustomerID = Customers.ID WHERE Sales.Date >= DATEADD(quarter, -1, GETDATE());
C
SELECT SUM(Sales.Amount) AS TotalSales, Products.Name AS ProductName, Customers.Name AS CustomerName FROM Sales JOIN Products ON Sales.ProductID = Products.ID JOIN Customers ON Sales.CustomerID = Customers.ID GROUP BY Products.Name, Customers.Name;
D
SELECT Sales.Amount AS TotalSales, Products.Name AS ProductName, Customers.Name AS CustomerName FROM Sales JOIN Products ON Sales.ProductID = Products.ID JOIN Customers ON Sales.CustomerID = Customers.ID;