Keep only N last records in SQLite database, sorted by date

Viewed 15882

I have an SQLite database that I need to do the following: Keep only last N records, sorted by date. How do you do that?

5 Answers

I wonder if this is faster or slower than Jackob solution. sqlitebrowser says 0ms for both...

DELETE FROM test WHERE date < ( SELECT date FROM test ORDER BY date DESC LIMIT 1 OFFSET 9 )
Related