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 desc 
limit 1;
select t.*
from test t
where t.value = @lastValue
  and > (select max( from test tt where tt.value <> @lastValue)
order by asc
limit 1;

You can test on this db<>fiddle

Browse More Popular Posts

Leave a Comment