Fix #174

Quick fix to GROUP BY clause on pgsql < 9.0