I have a table in SQL Server and I'm having a hard time making a query.
I have a table like this:
alunos
ra nome serie cod_curso
23 joão 1 EI
23 joão 2 EI
23 joão 3 EI
44 maria 5 EF
44 maria 6 EF
61 jose 10 CCO
32 ana 7 PED
78 ana 8 PED
I need to select the highest value of serie
for each ra
. The result of the query should look like this:
alunos
ra nome serie cod_curso
23 joão 3 EI
44 maria 6 EF
61 jose 10 CCO
78 ana 8 PED
If I select MAX(serie)
but it will not work. I need to select MAX(serie)
according to each ra
, but I do not know how to do that.