Postgresql Json Build Object Group By Having