Я пытаюсь выполнить приведенный ниже запрос в PostgreSQL, но получаю ошибку как
column "r.role_id" must appear in the GROUP BY clause or be used in an aggregate function
Запрос
select u.user_id, sso, r.role_id, r.role, u.created_time,
u.created_by, u.updated_time, u.updated_by, u.last_logged_in,u.first_name,u.last_name,
array_agg(distinct c.country_name) as country_name,
array_agg(distinct m.modality) as modality,
u.sfdc_access from cimt.user u
left join user_modality um on um.user_id = u.user_id
left join modality m on m.modality_id = um.modality_id
left join user_country uc on uc.user_id = u.user_id
left join country c on c.country_id = uc.country_id
inner join role r on r.role_id = u.role_id
group by u.user_id;