Suppose you have a table with snapshots of accounts from the past 4 years, 1 row per date/account pair. (Note accounts don't need to have a row for every day).
For simplicity suppose there are 3 columns: acct_number
, date
and balance
. How would you add 2 more columns to each row that are the date/balance for that account for the previous date recorded in the table?
It seems like sorting by acct_number
and date then "offsetting by one" and joining to the original table is a promising approach but I don't know how you'd implement this.