問題文
A staging table contains multiple versions of each customer record, one per extract, with an extracted_at timestamp. The analyst needs exactly one row per customer, keeping the newest version. Which query shape is the most direct?
選択肢
- Group by customer with a MAX on the timestamp, which returns the newest version of every column for each customer because the grouping keeps that row intact.
- Number the rows within each customer by descending timestamp with a window function, then keep the rows numbered one using QUALIFY.
- Order the result by timestamp descending for the customer column and add a LIMIT equal to the number of distinct customers.
- Select distinct on the customer column, which keeps the row from the staging table and the extracts with the highest timestamp for each value.