SELECT a.id_alu AS `CÓDIGO`,a.ape_per AS `APELLIDOS`,a.nom_per AS `NOMBRES`,g.des_gra AS `GRADO`,
c.des_cur AS `CURSO`,
 CASE ag.est_cupo WHEN 'a' THEN 'APROBADO'
	WHEN 'n' THEN 'REPROBADO'
	ELSE 'PENDIENTE' END AS `ESTADO`,dif.ob_est AS `OBSERVACIÓN`
FROM alum_grado ag
INNER JOIN alumno a USING(id_alu)
INNER JOIN grado g USING(cod_gra)
INNER JOIN alumcurso ac USING(id_alu)
INNER JOIN curso c USING(cod_cur)
LEFT JOIN est_dif_cup dif ON ag.id_alu=dif.id_alu AND dif.id_cuo=-1
WHERE ag.cod_gra LIKE 'VAR01'
ORDER BY g.ord_gra,c.cod_cur,ag.est_cupo,a.ape_per,a.ape_per