the statement is following: get the name and ID of the students with the highest grade in the subject with the code 46322
The structure of the database is this:
alumnos (dni pk, nombre, dirección, localidad)
asignaturas (coda pk, nombreas, curso,dpt)
expedientes ((dni,coda)pk, y fk, convocatoria, nota)
The query I have raised it like this:
select nombre, nombrea, convocatoria
from alumnos inner join expedientes on (expedientes.dni=alumnos.dni) inner join asignaturas on (asignaturas.coda=expedientes.coda)
where exists (select max(nota)
from expedientes
where (coda=47322 ) and (convocatoria like 'junio') );
However, it returns incorrect values. Thanks for the help.