get first occurrence of last changed value of a column [closed]

Maybe you can try with something like this:

select t.value into @lastValue
from test t 
order by t.date desc 
limit 1;
    
select t.*
from test t
where t.value = @lastValue
  and t.date > (select max(tt.date) from test tt where tt.value <> @lastValue)
order by t.date asc
limit 1;

You can test on this db<>fiddle

Leave a Comment