Вы можете использовать функции условного агрегирования и json:
select
jsonb_agg(jsonb_build_object('id', id, 'title', title))
filter(where category = 'main') main,
jsonb_agg(jsonb_build_object('id', id, 'title', title))
filter(where category = 'drink') drink,
jsonb_agg(jsonb_build_object('id', id, 'title', title))
filter(where category = 'side') side
from mytable
Демонстрация на DB Fiddle :
main | drink | side
:------------------------------------------------------------- | :----------------------------------------------------------- | :-------------------------------------------------------------
[{"id": "1", "title": "pizza"}, {"id": "2", "title": "pasta"}] | [{"id": "3", "title": "coke"}, {"id": "4", "title": "beer"}] | [{"id": "5", "title": "fries"}, {"id": "6", "title": "chips"}]