select a.ronda_id as Ronda, (select first_name||' '||last_name from auth_user where id = a.juez_id ) as Juez, (select nombre from "CertamenTabasco_municipio" where id in (select municipio_id from "CertamenTabasco_participante" where id = a.participante_id) ) as Participante, sum(a.calificacion) from "CertamenTabasco_calificacion" a group by a.ronda_id, a.participante_id, a.juez_id order by 1, 3, 2