Exam Preparation Quiz

Question 2 of 75

Query latest customer records

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:

Learn more about window functions in T-SQL.
Window Functions
Next Question