开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜