Which window function should fill the placeholder to return the most recent row per CustomerID?

Prepare for the DP-600 Fabric Analytics Engineer Exam. Study with flashcards and multiple choice questions, each offering hints and detailed explanations. Enhance your chances of success on the exam!

Multiple Choice

Which window function should fill the placeholder to return the most recent row per CustomerID?

Explanation:
The idea is to assign a unique order to rows within each CustomerID so you can pick exactly one row—the most recent one. Using ROW_NUMBER() with an order by a timestamp column in descending order creates a per-CustomerID sequence like 1, 2, 3, and you can then take the row where the sequence equals 1 to get the most recent entry. RANK() and DENSE_RANK() would assign the same rank to ties for the most recent date, which could yield multiple rows per customer. MAX() is an aggregate, not a row-identifier you can filter on to return a single per-CustomerID row without additional joins. So ROW_NUMBER() is the best fit to return the most recent row per CustomerID.

The idea is to assign a unique order to rows within each CustomerID so you can pick exactly one row—the most recent one. Using ROW_NUMBER() with an order by a timestamp column in descending order creates a per-CustomerID sequence like 1, 2, 3, and you can then take the row where the sequence equals 1 to get the most recent entry. RANK() and DENSE_RANK() would assign the same rank to ties for the most recent date, which could yield multiple rows per customer. MAX() is an aggregate, not a row-identifier you can filter on to return a single per-CustomerID row without additional joins. So ROW_NUMBER() is the best fit to return the most recent row per CustomerID.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy