아래와 같이 tbl_a라는 테이블이 있습니다.
tbl_a
--------
seq_no
1
1
2
3
.
.
.
--------
오라클의 경우는 이런식으로 했습니다.
1. 먼저 중복된 값을 찾는다.
select seq_no,count(seq_no)
from tbl_a
group by seq_no
having by count(seq_no) >1
2. 중복된 값을 rowid가 max인값이거나 (min인값)을 삭제한다.
delete
from tbl_a A
where rowid > ( select min(rowid)
from tbl_a B
where b.seq_no = a.seq_no)
and seq_no = '1'; <-중복된 값중에 삭제하고싶은값
DB2는 한지 얼마 안되서 잘 모르겠더군요. 어떻게 해야 되는지 답변좀 부탁드립니다. 위의 2번의 쿼리를 모르겠습니다. db2에서도 rowid가 있는지 찾아봤는데
보이진 않고 row_number() over()이것이 보이던데..이것으로 대체가 될까요?
|