 
     FOR r IN
         SELECT
+            gl.job_type,
             count(*) AS instance_count,
             coalesce(sum(gl.average_jobs), 0) AS current_jobs,
             coalesce(sum(gl.max_jobs), 0) AS max_jobs

        GROUP BY
            gl.job_type
    LOOP
        instance_count := r.instance_count;
        current_jobs := r.current_jobs;
        max_jobs := r.max_jobs;

        IN group_name text,
        IN current_interval interval
    ) RETURNS TABLE (
        job_type text,
        instance_count integer,
        current_jobs double precision,
        max_jobs double precision,
