Window functions work out a value for each row from a set of related rows, without collapsing them: ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_ts DESC) numbers each customer's orders from newest to oldest.
In most databases you can't filter on that number in WHERE, because windows are worked out after WHERE. You'd wrap the query in a subquery. Snowflake has QUALIFY, a filter that runs after the window functions:
SELECT customer_id, order_id, order_ts
FROM orders
QUALIFY ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_ts DESC) = 1;
That's the standard way to keep the latest row per key, and to remove duplicates from a feed. If two rows tie on the sort, ROW_NUMBER picks one at random, so add a tie-breaker to the ORDER BY. RANK keeps ties instead.