A window expression computes a value for each row without collapsing its group. WHERE runs before that calculation. QUALIFY filters after it, so you can keep the latest order for each customer without putting the ranking inside a separate subquery. An equivalent subquery is also valid.
Choose the ranking function from the business rule. ROW_NUMBER keeps a fixed number of rows, while RANK can keep several tied rows. A latest-record rule needs a deterministic tie breaker when two orders share a timestamp. Aster Supply uses ordered_at followed by id for that purpose. NULL customer identifiers form one window partition; decide whether that partition belongs in your output rather than accidentally removing it with a join. These tasks compare actual rows on a second feed, so returning the currently largest identifiers alone will not establish the ranking rule.