메뉴 건너뛰기

tnt_db

Oracle 중복 data를 찾아 한번만 display하는 방법

운영자 2002.11.23 10:38 조회 수 : 3428 추천:34

SQL> select rowid,deptno,dname,loc from dept;

ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAAlXAAEAAAA53AAA          0 ss             tt
AAAAlXAAEAAAA53AAB          1 tt             ii
AAAAlXAAEAAAA53AAC          2 yy             gg
AAAAlXAAEAAAA53AAD          1 tt             uu
AAAAlXAAEAAAA53AAF          0 smlee          insert        


1)
SQL> select * from dept a where rowid < (select max(ROWID) from dept where dept.deptno =a.deptno)  
    DEPTNO DNAME          LOC
---------- -------------- -------------
         0 ss             tt
         1 tt             ii    
2)
SQL> select * from dept e WHERE rowid >
      (SELECT min(rowid) FROM dept X WHERE X.Deptno = E.deptno);        

    DEPTNO DNAME          LOC
---------- -------------- -------------
         0 smlee          insert
         1 tt             uu
위로