 on (slr.respondent_id=raw.respondent_id)
 left join who_coded_what wcw
 on (slr.respondent_id=wcw.respondent_id)
-order by priority, raw.start_date, respondent_id
+left join automated 
+on (slr.respondent_id=automated.respondent_id)
+order by priority, raw.start_date desc, respondent_id
 )
-select * from final_priority where priority < 7);
+select * from final_priority where priority < 10);
 

from ratio_table
group by respondent_id
),
who_coded_what as (
select respondent_id, array_agg(distinct classified.coder_id) as coders, count(pii or null) as pii
from classified 
group by respondent_id
),
final_priority as (

        wcw.coders,
        wcw.pii,
        case 
            when automated.automated = 1 then 4
            when wcw.pii > 0 then 8
            -- When there is a majority, but less than 3 people coded
            when (slr.ratio > 0.5 and slr.total > 1 and slr.total < 5)
