Having a table below, I need to get rows with the maximum date having statut equal 2
REMUN_ID HISTO_ID DATE_MAJ STATUT 2122 700
select remun_id, date_maj from ( select r.*, max(date_maj) over (partition by REMUN_ID) as max_date from histo_statut_remun r ) where date_maj = max_date and statut = 2;
SQLFiddle: http://sqlfiddle.com/#!4/7eb75/1