You need to GROUP BY all non aggregate functions