我需要一个命令,可以从作者那里选出最多的积极问题,例如,结果应如下所示:

Author     WithTheMostMax
Author1                2


作者表

AuthorID    AuthorName
Author1    AuthorName1
Author2    AuthorName2
Author3    AuthorName3


问题清单

AuthorID    Issues
Author1          1
Author2          0
Author3          0
Author1          1

最佳答案

SELECT AuthorName, SUM(Issues) AS WithTheMostMax FROM issues_list INNER JOIN issues_list.AuthorID = author_table.AuthorID
GROUP BY AuthorName ORDER BY SUM(Issues) DESC

09-11 19:18