row_number() over(partition by SO.join_id order by PO.something) as r
并抑制 .* 的行的输出r > 1
。
更新:您不一定需要按连接条件进行分区。按您想要抑制的任何内容进行分区。
13:35:44 SYSTEM@dwal> ed
Wrote file S:\\tools\buffer.sql
1 select decode(rn, 1, owner) owner, object_type, cnt
2 from (
3 select owner, object_type, count(*) cnt,
4 row_number() over(partition by owner order by owner, object_type desc) rn
5 from dba_objects
6 where owner in( 'SYSTEM', 'OUTLN')
7 group by owner, object_type
8* )
13:36:09 SYSTEM@dwal> / </s>
OWNER OBJECT_TYPE CNT
-------- ------------------- ----------
OUTLN TABLE 3
PROCEDURE 1
LOB 1
INDEX 5
SYSTEM VIEW 14
TYPE 1
TRIGGER 2
TABLE PARTITION 47
TABLE 159
SYNONYM 8
SEQUENCE 20
QUEUE 4
PROCEDURE 1
PACKAGE BODY 1
PACKAGE 1
LOB 23
INDEX PARTITION 72
OWNER OBJECT_TYPE CNT
-------- ------------------- ----------
INDEX 239
18 rows selected.
在这种情况下,您将需要对多个列进行多次分析,这很昂贵