0
Staff I am using this command on sqlserver:
SELECT ALUNOS.NOME, DISCIPLINAS.NOME AS DISCIPLINA, MAX(NOTAS.NOTA) AS MEDIA FROM NOTAS
INNER JOIN ALUNO_DISCIPLINA ON ALUNO_DISCIPLINA.identificacao = NOTAS.codAlunoDisciplina
INNER JOIN DISCIPLINAS ON ALUNO_DISCIPLINA.CODIGO_DISCIPLINA = DISCIPLINAS.CODIGO
INNER JOIN ALUNOS ON ALUNO_DISCIPLINA.registro_aluno = ALUNOS.Registro
GROUP BY DISCIPLINAS.NOME,ALUNOS.NOME
ORDER BY DISCIPLINAS.NOME
Then the result generates the following table according to the image
I would like you to show only (MARIA Geography 9.00) and (JOÃO Portugues 10.00), which are the highest grades of the students, that is to compare between Portuguese and show the highest note tbm. Any suggestions where I’m going wrong??
Which DBMS you are using?
– Sorack
sql server management studio 2014
– Abism
@Abism your question is not clear... do you need the student who got the highest grade per discipline? Should it be considered average or only grade? And if there are students with the same grades, bring them both? Since you are new here I suggest you read [mcve].
– mateusalxd
Look, Matthew, I wouldn’t have thought of that if I had students with the same grade in the same class!! But the correct thing would be to return the student, discipline and the highest grade in the subject, if there was another student with the same grade tbm would bring it in the table, so I’m using the MAX.
– Abism