You work for MDFT Academy, a well-known training agency. You have a data warehouse that contains a table named Stage.Customers which contains all the customer update records that have been imported from a customer relationship management (CRM) system. There can be multiple updates per customer.
You need to write a T-SQL query that will return the customer ID, name, postal code, and the last updated time of the most recent row for each customer ID. You have the following query:
WITH CUSTOMERBASE AS (
SELECT [CustomerID]
, [CustomerName]
, [PostalCode]
, [LastUpdated]
, x = ___________
OVER (PARTITION BY CustomerID
ORDER BY LastUpdated DESC)
FROM [LakehousePOC].[dbo].[CustomerChanges])
SELECT CustomerID, CustomerName, PostalCode, LastUpdated
FROM CUSTOMERBASE
WHERE x = 1
How should you complete the missing part of the query?
Choose the correct answer from the options below.
Explanations for each answer: