QuestionQ104
Prepare dataYou have a data warehouse containing a table named Stage.Customers. It stores every customer-record update from a customer relationship management (CRM) system, and a customer can have multiple updates.
You need a T-SQL query that returns the customer ID, name, postal code, and last-updated time from the most recent row for each customer ID.
How should you complete the code?
Select
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
Community Discussion