I have been looking around and facing an issue that I don’t see how to solve
I have the following query with rather simple data
SELECT distinct jsonb_build_object('entity', (select json_agg(t)
from (
select jsonb_build_object(
'active',false
,'descriptionPersonne', (select jsonb_build_object('a','a'))
) as personne
union
select jsonb_build_object(
'active',false
,'descriptionCompany', (select jsonb_build_object('a','a'))
) as company
)t)
)
my results look like this
{"entity": [
{"**personne**": {"descriptionCompany": {"a": "a"}, "active": false}},
{"personne": {"descriptionPersonne": {"a": "a"}, "active": false}}
]}
I don’t get why my first results is a personne and not a company
I have tried many other options like having a with statement, or json_build_array
New contributor
guillaume is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.