seq name birth date
1 홍길동 19990101 20161108
2 홍길동 19990101 20150707
3 손오공 20001211 20160505
4 손오공 20001211 20150101
위데이터를 (이름 생년월일) 키값으로 seq값이 제일 큰 값만 불러오고 싶습니다..
in쿼리 안에 select max(seq) from table group by name, birth
이렇게 하면 결과값이 나오는데 건수가 많을 경우 느리네요 ㅠㅠ
부탁드립니다
결과값
seq name birth date
2 홍길동 19990101 20150707
4 손오공 20001211 20150101
with t (seq,nm,birth,dt) as ( select 1,'홍길동','19990101','20161108' from dual union all select 2,'홍길동','19990101','20150707' from dual union all select 3,'손오공','20001211','20160505' from dual union all select 4,'손오공','20001211','20150101' from dual ) select seq, nm, birth, dt from ( select t.* , row_number() over(partition by nm order by seq desc) rn from t) where rn = 1