Each sugar names a ritual: QUALIFY = the subquery-then-filter of top_n_per_group; GROUP BY ALL = 'group by everything I didn't aggregate' (with the caution that an added SELECT column silently changes the grouping); EXCLUDE = 'all but these'. The portability tax is the second half: none is universal — code that ships to Postgres expands QUALIFY back to the subquery, ALL back to the explicit list, EXCLUDE back to named columns.
SELECT cart, twist FROM carts QUALIFY ROW_NUMBER() OVER ( PARTITION BY cart ORDER BY n DESC ) = 1 ORDER BY cart;
SELECT cart, twist FROM ( SELECT cart, twist, ROW_NUMBER() OVER ( PARTITION BY cart ORDER BY n DESC ) AS rn FROM carts ) WHERE rn = 1 ORDER BY cart;
Both return the best twist per cart, but QUALIFY is engine sugar — it filters the window inline where DuckDB/Snowflake/BigQuery allow it, and code that ships to Postgres must expand it back to the subquery-then-filter.
Use them where they live; keep the portable expansion next to anything that travels.
QUALIFY / GROUP BY ALL / SELECT * EXCLUDE in DuckDB/Snowflake/BigQuery; Postgres needs the explicit expansions.