Note that another workaround for top-level queries, other then obviously using jsonb instead of json as column type, would be grouping by the entity's primary key, e.g. group by b.id in your example, that will work on DBs that support functional group by dependency like PostgreSQL. |