title: Delete top 1 row using SQL
body: <p>I have a SQL, the purpose is to keep the last two entries and delete the top rows .    </p>
  
  <pre><code>delete from table 
  where RowID in (select top 10 RowID from table) 
  </code></pre>
  
  <p>This deletes all rows instead of the first rows I intend to delete.</p>
  
  <p>In the interface I am using, 'WITH' command does not work. It has to be something like the above query. </p>
  
  <p>I have a table with 3 columns <code>x, y, z</code>. I can't rely on the pseudo column rownum as when I delete some rows the rownum don't change. As this delete query will be running every 60 sec and the rownum of the table won't start from 1 every time.</p>
  
  <p>I want to delete all other rows except the last two entries. <code>Top</code> will work </p>
  
  <pre><code>delete from custom.colperformance 
  where RowID in (select top 2 RowID 
                  from custom.colperformance 
                  order by RowID desc)
  </code></pre>
  
  <p>This is giving me an error </p>
  
  <pre><code>    Table structure 
  
  ProfileTime   TriggerTime  RowId
  12            3             4
  12            5             6
  6             7             2
  </code></pre>
  
  <p>here Rowid comes in random if we delete some rows in between </p>
  
  <p>Please help!! .. thanks in advance </p>