I have a MySQL table as below.
**AuthorID**, **PublicationName**, ReferenceCount, CitationCount
AuthorID and PublicationName act as the primary key. I need to find the maximum sum of ReferenceCount and CitationCount for all the authors. For example, the data is as below.
1 AAA 2 5
1 BBB 1 3
1 CCC 2 4
2 AAA 1 4
In this case, I need my output as,
1 AAA 7
2 AAA 5
I tried the below query.
SELECT AuthorID, PublicationName, Max(Sum(ReferenceCount + CitationCount))
from Author
Group by AuthorID, PublicationName
If I use max(sum(ReferenceCount + CitationCount)) group by AuthorID, PublicationName I get an error as "Invalid use of Group function". I believe I should include Having clause in my query. But am not sure on how to do the same.