Sql Compact 3.5: Limit number of rows in column
I have a table with rows of the following form: Timestamp D开发者_如何学编程ata: I would like to keep only newest N rows in table, and delete everything rest.
Is there a way to specify deletion of all except N newest rows?
delete from table
where id not in (
select top 30 id from table
order by timestampcolumn desc
)
Here N = 30
. You can replace the number 30 by any number you want to retain.
精彩评论