Hi, I have a very complicated query (to me anyway!) that includes an aggregate function. It works fine when I Select only the authorpub.medlineauthorname, but when I include authorpub.rank I get the following error: runtime error 2147217887 "You tried to execute a query that does not include the specified expression 'rank' as part of an aggregate function." Could someone please explain how I can accomplish this? Thank you. PT
"SELECT count(*), authorpub.medlineauthorname, author.rank From AuthorPub " _
& "INNER JOIN author ON authorpub.medlineauthorname = author.medlineauthorname " _
& "WHERE authorpub.MedlineID IN " _
& "(SELECT authorpub.MedlineID FROM AuthorPub WHERE authorpub.MedlineAuthorName = " _
& "'" & strSelectedAuthor & "') " _
& "AND authorpub.MedlineAuthorName <> '" & strSelectedAuthor & "' " _
& "GROUP BY authorpub.MedlineAuthorName " _
& "ORDER BY count(*) desc;"
"SELECT count(*), authorpub.medlineauthorname, author.rank From AuthorPub " _
& "INNER JOIN author ON authorpub.medlineauthorname = author.medlineauthorname " _
& "WHERE authorpub.MedlineID IN " _
& "(SELECT authorpub.MedlineID FROM AuthorPub WHERE authorpub.MedlineAuthorName = " _
& "'" & strSelectedAuthor & "') " _
& "AND authorpub.MedlineAuthorName <> '" & strSelectedAuthor & "' " _
& "GROUP BY authorpub.MedlineAuthorName " _
& "ORDER BY count(*) desc;"