
Ultimate access to all questions.
You are tasked with querying a warehouse in Fabric to extract inventory data for the current year. The warehouse contains a table named 'Inventory' with columns 'ItemID', 'ItemName', 'StockDate', and 'Quantity'. Write a SQL query that retrieves the total quantity of each item for the current year. How would you structure this query?
A
SELECT ItemID, ItemName, SUM(Quantity) AS TotalQuantity FROM Inventory WHERE StockDate >= DATEADD(year, DATEDIFF(year, 0, GETDATE()), 0) GROUP BY ItemID, ItemName;
B
SELECT ItemID, ItemName, SUM(Quantity) AS TotalQuantity FROM Inventory GROUP BY ItemID, ItemName;
C
SELECT ItemID, ItemName, Quantity AS TotalQuantity FROM Inventory WHERE StockDate >= DATEADD(year, DATEDIFF(year, 0, GETDATE()), 0);
D
SELECT ItemID, ItemName, Quantity AS TotalQuantity FROM Inventory;