SELECT user_id, ordered_on, amount,
LAST_VALUE(amount) OVER (
PARTITION BY user_id ORDER BY ordered_on, order_id
) AS last_default,
LAST_VALUE(ordered_on) OVER (
PARTITION BY user_id ORDER BY ordered_on, order_id
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS last_date
FROM orders
ORDER BY user_id, ordered_on;
The two frames for user 1's first order:
The default frame ends at the current row and its peers. This window sorts on a unique key, so there are no peers. LAST_VALUE never sees the later orders, and hands back the current amount. last_date widens the frame to the whole partition, from UNBOUNDED PRECEDING to UNBOUNDED FOLLOWING, and every row gets the user's last date.
FIRST_VALUE doesn't have this problem, because the default frame always starts at the partition's first row.
In the editor, write LAST_AMOUNT: each user's last order amount, on every row.