PostgreSQL - Group By Primary Key Bug