Ниже вариант запроса (PostgreSQL) который собирает всё в один JSON:
SELECT row_to_json(client.*)
FROM (
SELECT
clients.*,
json_agg(
row_to_json(trainers.*)
) trainers
FROM
clients
JOIN trainers ON trainers.t_id < clients.t_id
where
clients.t_id = 10
GROUP BY clients.t_id, clients.t_name, clients.t_phone
) client;
SQL fiddle
Вариант PL\SQL:
SELECT json_object(
't_id' VALUE client.t_id,
't_name' VALUE client.t_name,
't_phone' VALUE client.t_phone,
't_trainers' VALUE client.trainers
) FROM (
SELECT
clients.*,
json_arrayagg(json_object(
't_id' VALUE trainers.t_id,
't_name' VALUE trainers.t_name,
't_phone' VALUE trainers.t_phone
)) trainers
FROM
clients
JOIN trainers ON trainers.t_id < clients.t_id
where
clients.t_id = 10
GROUP BY clients.t_id, clients.t_name, clients.t_phone
) client;