Why this code cannot delete the rows that i want? i want keep the 100 rows that has the biggest timestamp and delete all the other rows... Here follow the code that i have create :

$values_to_delete = db_delete('table1', 't');
  $values_to_delete-&gt;orderBy('t.timestamp');
  $values_to_delete-&gt;range(101, 99999999);
  $values_to_delete-&gt;execute();
The DeleteQuery class doesn't have orderBy or range functions, so I would imagine you would need to write your own DELETE with SELECT subquery. An example from Stack Overflow