Postgres is really picky about queries containing GROUP BY. Every column which
isn't listed in the GROUP BY clause has to be wrapped up in an aggregate
function.
The problem was that we were generating queries like this:
SELECT karmastats.receiver AS karmastats_receiver, sum(karmastats.kcount) AS anon_1
FROM karmastats GROUP BY karmastats.receiver ORDER BY karmastats.kcount
Note the unadorned karmastats.kcount in the ORDER BY clause. The fix is to use
sum(karmastats.kcount) everywhere.
Postgres is really picky about queries containing GROUP BY. Every column which isn't listed in the GROUP BY clause has to be wrapped up in an aggregate function.
The problem was that we were generating queries like this:
Note the unadorned karmastats.kcount in the ORDER BY clause. The fix is to use sum(karmastats.kcount) everywhere.