Get first or last value in a group

For most SQL dialects, the easiest way to get the first (or last) value within groups is probably to add a row number, and then filter on 1 in the next step:

If you want to get the last value, just use ORDER BY balance_updated_at DESC