MySQL - select maximum sum -
i have mysql table below.
**authorid**, **publicationname**, referencecount, citationcount authorid , publicationname act primary key. need find maximum sum of referencecount , citationcount authors. example, data below.
1 aaa 2 5 1 bbb 1 3 1 ccc 2 4 2 aaa 1 4 in case, need output as,
1 aaa 7 2 aaa 5 i tried below query.
select authorid, publicationname, max(sum(referencecount + citationcount)) author group authorid, publicationname if use max(sum(referencecount + citationcount)) group authorid, publicationname error "invalid use of group function". believe should include having clause in query. not sure on how same.
if understand question right, want records publication has citations. publication , citation counts given by:
select publicationname, sum(referencecount + citationcount) author group publicationname order sum(referencecount + citationcount) desc limit 1; the order by , limit 1 give highest value.
if want records publication maximum sum:
select a.* author join (select publicationname, sum(referencecount + citationcount) author group publicationname order sum(referencecount + citationcount) desc limit 1 ) asum on a.publicationname = asum.publicationname
Comments
Post a Comment