I have a database table with columns account_id, day, balance. It holds the end-of-day balances per account, so all accounts have 1 record per day, so account_id+day is UK. I'd like to copy this data into another table with columns account_id, balance, valid_from, valid_to, so if the balance is unchanged between say April 1 and April 10, there is a single row instead of 10, as in the original table. Can you write the SQL that transforms the original data into the new table?