karma: Fix --top and --bottom on PostgreSQL.
karma: Fix --top and --bottom on PostgreSQL.

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.

iankronquist/hamper,hamperbot/hamper,maxking/hamper