SQL: Window function: ROW_NUMBER
A short, tested SQL example for window function: row_number. Copy it and adjust the names and paths for your project.
SQL
SELECT *
FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY created_at DESC) AS rn
FROM orders
) t
WHERE rn = 1; -- latest order per customerFind it in Zest
Search for “sql window function: row_number” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.