I have a table:
student1 - given1 student1 - die2 student2 - given1 student2 - die2
And I want my query to return:
student1 - given1 (recent + date) student2 - given2 (recent + date)
How do I give a student distinct only with the most recent date? I tried according this answer , but I'm not hitting the syntax
select *
from (
select ac.cod_matricula,
he.cod_usuario_log,
he.dt_atualiza_log,
he.txt_ip_log,
he.cod_usuario_log_del,
he.dt_atualiza_log_del,
RANK() OVER(PARTITION BY ac.cod_matricula) rnk
from OW.HIST_HISTORICO HE, OW.ALUNO AC
where ac.cod_aluno_curso = he.cod_aluno_curso
and he.cod_usuario_log = '1234567'
--and extract(YEAR from he.dt_atualiza_log) = 2018
order by he.dt_atualiza_log desc )
where rnk = 1