A window function works out a value for each row from related rows, without collapsing them. ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC) numbers each customer's orders from newest to oldest; SUM(x) OVER (ORDER BY day) is a running total; LAG(x) OVER (...) reads the previous row.
To filter on a window function, BigQuery supports QUALIFY, which runs after the windows are worked out:
SELECT customer_id, order_id, order_date
FROM shop.orders
QUALIFY ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date DESC) = 1;
That keeps each customer's latest order: the standard way to deduplicate. If two rows tie on the sort, add a tie-breaker, here order_id, so the result doesn't change from run to run. RANK and DENSE_RANK keep ties instead.