The problem is to find the last day when a cumulative reading changed. It could be solved by order by max energy desceding, followed by ordering by the start date ```sql select interval_start_at from cumulative_readings where metering_system_id = 123 order by max_energy_wh desc, interval_start_at asc limit 1 ```