I'm writing a script to check RSS feeds on regular intervals and need to prune out old articles. I came across this answer which seems really close to what I'm looking for: SQL query: Delete all records from the table except latest N?
I need a similar solution that works the same way, except it keeps N articles per feed (and not N articles in general). Each article has a field named "RSSFeedID" which references a specific feed in another table. So for each RSSFeedID, I need to keep only N articles.
Any idea on how to do this? Either the raw SQL query or LINQ-to-SQL code would be very helpful. Thanks!