请教给位前辈,下面这个sql怎么写?
现有表如下:
aticle 文章表
id(主键自增) title member_id(作者) views(访问量) content
comment 评论表
id(主键自增) parent_id(对应文章id) content
give 投稿表
id(主键自增) title member_id(作者) content
取前5个作者的: 被录用总文章数、被录用文章总访问量、被录用文章总评论数、总投稿数
排序:被录用总文章数、被录用文章总评论数、被录用文章总访问量、总投稿数
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