🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[https://www.zhihu.com/question/327253526](https://www.zhihu.com/question/327253526) Top1 查文章列表分页并附带各自评论数点赞数最高的评论 ``` SELECT a.*,b.max_score from sc a INNER JOIN ( SELECT CId,max(score) max_score from sc GROUP BY CId ) b on a.CId= b.CId and a.score= b.max_score; ``` TopN 查文章列表分裂并附带各自评论数点赞数前5的评论 ``` select * from comment c where parent_id in ({ids}) and (select count(*) from comment s where c.parent_id = s.parent_id and c.created_at < s.created_at) < 5 ```