如何计算一组的最大值?

时间:2016-05-18 10:16:43

标签: php mysql

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

Author     WithTheMostMax
Author1                2

AUTHOR TABLE

AuthorID    AuthorName
Author1    AuthorName1
Author2    AuthorName2
Author3    AuthorName3

问题列表

AuthorID    Issues
Author1          1
Author2          0
Author3          0
Author1          1

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

如果问题表中的每一行都存储了每个作者1个问题,则可以使用Entity Framework to 6.0

count()

http://sqlfiddle.com/#!9/bbb79/2