group by having count postgresql