select Name, Keyword, Label from (
SELECT
  usr_institution.keyword as Name,
  tm_system.keyword as Keyword,
  sys_table_session.table_keyword as Label
FROM
  public.sys_table_session,
  public.tm_system_in_session,
    public.usr_institution,
  public.tm_institution_system,
  public.tm_system
WHERE
  tm_system_in_session.table_session_id = sys_table_session.id AND
  tm_system.id = tm_system_in_session.system_id AND
   tm_institution_system.institution_id = usr_institution.id AND
  tm_institution_system.system_id = tm_system.id and
  tm_system_in_session.testing_session_id = 38
  union
select trim(trailing ', ' from name) as Name, keyword, label from (
  select cast (textcat_all(name || ', ') as varchar) as name, cast('' as varchar) as Keyword, label from (SELECT
  initcap(usr_users.firstname) || ' ' || initcap(usr_users.lastname) as name,
  '' as keyword,
  tm_user_preferences.connectathon_table as Label
FROM
  public.usr_users,
  public.usr_role,
  public.usr_user_role,
  public.tm_monitor_in_session,
  public.tm_user_preferences
WHERE
  usr_user_role.user_id = usr_users.id AND
  usr_user_role.role_id = usr_role.id AND
  tm_monitor_in_session.user_id = usr_users.id AND
  tm_monitor_in_session.is_activated = 't' AND
  tm_user_preferences.user_id = usr_user_role.user_id AND
  usr_role.id = 3 AND
  tm_monitor_in_session.testing_session_id = 38) as foo1 group by label  ) as foo2) as foo
where Label != 'None'
order by label asc ;