title: get first occurrence of last changed value of a column
body: <p>How to get first occurrence of last changed value of &quot;sval&quot; column?</p>
  <p><a href="https://dbfiddle.uk/?rdbms=mariadb_10.6&amp;fiddle=c980809154d41f2accc9f14d569b48f1" rel="nofollow noreferrer">https://dbfiddle.uk/?rdbms=mariadb_10.6&amp;fiddle=c980809154d41f2accc9f14d569b48f1</a></p>
  <p><strong>data:</strong></p>
  <p><a href="https://i.stack.imgur.com/4qaWB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4qaWB.png" alt="enter image description here" /></a></p>
  <p>in above picture i wanted to fetch highlighted row.</p>
  <p><strong>try:</strong></p>
  <pre><code>with LastValue as (
    select t.sval
    from test t 
    order by t.date desc 
    limit 1
  )
  select t.*
  from test t
  where t.sval = (select sval from LastValue)
    and t.date &gt; (select max(tt.date) from test tt where tt.sval &lt;&gt; (select sval from LastValue))
  order by t.date asc
  limit 1;
  </code></pre>
  <p>actually the problem statement is i dont want the group by sval first occurence, instead i want the whatever last changed sval so our example after highlighted rows should be returns for ids (22,25).</p>