title: Query to Delete consecutive repeated values in large database in my SQL using phpmyadmin
body: <p>I have a table records with speed column in my database. Now the first 6 entries are same(consecutive repeated value) in different timestamp. I want to remove these repeated values a just take only single value.
  after some time the speed varies and become 200 and then again remain constant then my query should also delete that consecutive duplicate values from my table records.</p>
  <p>In simple words I want to filter my records table and make that table free from consecutive repeated values show only the single values in different timestamp.</p>
  <p>speed in records table of database:<br />
  <img src="https://i.stack.imgur.com/FAeK0.png" alt="speed in records table of database" /></p>
  <p>I've tried different queries to perform that some are these</p>
  <pre><code>DELETE t1 FROM records t1
  inner join records t2
  WHERE t1.speed = t2.speed AND t1.run_date_time &lt; t2.run_date_time
  
  DELETE FROM history 
  WHERE id IN (
  SELECT x.id
  FROM (             
    SELECT id
    FROM history AS h1
    WHERE 
        speed = (SELECT speed
                FROM history AS h2
                WHERE                     
                      h2.run_date_time &lt; h1.run_date_time
                ORDER BY run_date_time DESC 
                LIMIT 1)) AS x)
  </code></pre>