mysql sql根据投稿、评论、录用、访问量总数取出前5个作者
天蓬老师
天蓬老师 2017-04-17 11:07:40
0
1
676

请教给位前辈,下面这个sql怎么写?

现有表如下:
aticle 文章表
id(主键自增) title member_id(作者) views(访问量) content

comment 评论表
id(主键自增) parent_id(对应文章id) content

give 投稿表
id(主键自增) title member_id(作者) content

取前5个作者的: 被录用总文章数、被录用文章总访问量、被录用文章总评论数、总投稿数

排序:被录用总文章数、被录用文章总评论数、被录用文章总访问量、总投稿数

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
黄舟

Break it into several steps to be more effective

First take out the top 5 with the largest number of accepted articles and sort them (the subsequent sorting will be sorted among these 5, greatly reducing the sorted result set)

Then determine whether any of the above five authors has the same total number of accepted articles. If not, exit the sorting process; if yes, take out the total number of comments on the accepted articles of the authors with the same total number of accepted articles. According to this number, authors with the same total number of accepted articles are ranked

By analogy, the total number of views and total number of submissions for accepted articles

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template