日期:2014-05-17 浏览次数:20693 次
delete table c where no exists ( select 1 from (select 字段一,字段二 from (select a.*,row_number() over(partition by 字段一 order by 字段二 desc) rn from table a.*) where rn=1 ) b where c.字段一=b.字段一 and c.字段二=b.字段二 )
------解决方案--------------------
是想要这样的结果吗?如果不是请把相应的结果贴出来,请把想要的结果贴出来,你这样做,谁也无法明白你究竟想要什么。
SQL> SELECT DISTINCT FIELD1, NULL "FIELD2", DR 2 FROM ( 3 SELECT FIELD1, 4 DENSE_RANK() OVER(ORDER BY FIELD1) "DR" 5 FROM TABLE_NAME T 6 )TTT 7 UNION 8 SELECT NULL, 9 FIELD2, 10 DR 11 FROM ( 12 SELECT FIELD2, 13 DENSE_RANK() OVER(ORDER BY FIELD1) "DR" 14 FROM TABLE_NAME T 15 )TT 16 ORDER BY DR,1,2 DESC; FIELD1 FIELD2 DR ------ ---------- ---------- A 1 7 1 4 1 1 1 B 2 8 2 5 2 2 2 C 3 9 3 6 3 3 3 12 rows selected SQL>