TITLE | USER_GROUPS |
---|---|
Janitor | Users |
Secretary | Admin, Users |
1 with titles as (select title from testbed group by title),
2 title_count as (select title, user_group, count(*) as count_group from testbed group by title, user_group),
3 eid_count as (select title, count(distinct eid) eidcount from testbed group by title)
4 select t.title, listagg(tc.user_group, ', ') within group (order by user_group) user_groups from titles t
5 left join title_count tc on t.title = tc.title
6 left join eid_count e on t.title = e.title
7 where count_group = eidcount
8 group by t.title
9* order by title