postgresql group by having count