This issue is not about having an aggregate function in the select part or not. It's about the mismatching count of fields that are aggregated when the group by part is present (incorrect field list). Your error from the sqlfiddle already gave the answer: `ERROR: column "books.title" must appear in the GROUP BY clause or be used in an aggregate function: SELECT author,count(*),title FROM books GROUP BY author`. 
So one solution would be to drop that field in the select, which is not what we want, the other way is to extend the group key by all non-aggregated fields: `group by author,title`