I'm trying to generate a JSON with nested group arrays, however, I get the following error:
Result: misuse of aggregate function json_group_array()
I'm new to SQLite and I cannot see what is wrong with my query. When I remove the inner json_group_array and 'details' the query works.
select json_object('a',
json_group_array(
json_object(
'b', rm.id,
'c', '{}',
'd', l.code,
'details',
json_group_array(
json_object('e', rmd.id, 'f', rmd.s_id, 'g', s.name)
)
)
)
) as json
from...