postgresql group by count having