with t as ( select '001' "CD", 'AA' "NM", '2013-06-04' "DT" from dual union all select '002', 'BB', '2013-06-05' from dual union all select '003', 'AA', '2013-06-06' from dual union all select '004', 'CC', '2013-06-06' from dual union all select '005', 'AA', '2013-06-07' from dual union all select '006', 'DD', '2013-06-07' from dual union all select '007', 'AA', '2013-06-08' from dual ) select * from ( select nm,max(dt), rank() over(order by max(dt) desc) rk from t group by nm ) where rk < 4