Hey @ronasilb!
It looks like you're on the right path here. Someone very recently asked a similar question in this thread.
The suggestion there uses a separate Query JSON with SQL query but you might be able to just do the formatting you need in the join query you're creating. If you're using something like Postgres to query your data you can try using ARRAY_AGG, for instance:
SELECT
u.email,
ARRAY_AGG(o.status) AS order_statuses
FROM
users u
JOIN orders o ON u.id = o.user_id
GROUP BY
u.email;
From there you can use the nested list view notation.
Let me know if that helps or raises any other questions! There are likely other syntaxes that work for different resource types as well.