CREATE OR REPLACE FUNCTION public.fn_admin_list_guests()
 RETURNS TABLE(email text, name text, surname text, country text, tutor_id bigint, tutor_name text, tutor_surname text, reg_date timestamp without time zone)
 LANGUAGE sql
 STABLE
AS $function$
  SELECT
    guest_email::text,
    name::text,
    COALESCE(surname, '')::text,
    COALESCE(country::text, ''),
    tutor_id,
    tutor_name::text,
    COALESCE(tutor_surname, '')::text,
    reg_date::timestamp without time zone
  FROM public.vw_guest_with_tutor
  ORDER BY reg_date DESC
  LIMIT 500;
$function$
;
