Skip to content
Advertisement

SQL query: select five most commented posts from different blogs

I have a following tables Blogs(id) and Posts(id, blog_id, comment_count) I need to select five most commented posts from different blogs. It’s quite easy to do with a function, but is it possible to do with some kind of basic SQL?

Here’s the query in SQL Server dialect

Advertisement

Answer

UPDATE Hopefully it’s what you need. It’s not very fast though.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement