fixing PostgreSQL on heroku. try including aggregate function in the select query