select alu.id_alu as CODIGO, ape_per as APELLIDO ,nom_per as NOMBRE ,des_cur as SECCION, alu.prom from (
select cod_cur,max(prom) prom from( 
select s.cod_cur,id_alu,avg(round(nota_d,1)) as prom  from seg_final s ,periodo p,curso c,grado g
where p.per_not_fin='s' and per_fin='n' and p.id_peri=s.id_peri 
and c.cod_cur=s.cod_cur and g.cod_gra=c.cod_gra and cod_niv>1
group by s.cod_cur,id_alu
order by  cod_cur,prom desc
) p
group by cod_cur
order by  cod_cur,prom 
) pto 
inner join  (
select s.cod_cur,id_alu,avg(round(nota_d,1)) as prom  from seg_final s ,periodo p
where p.per_not_fin='s' and per_fin='n' and p.id_peri=s.id_peri 
group by s.cod_cur,id_alu
)alu on alu.cod_cur=pto.cod_cur and alu.prom=pto.prom
inner join alumno al on al.id_alu=alu.id_alu
inner join curso c on c.cod_cur=pto.cod_cur