select * from ( select tablespace_name,owner,segment_name,blocks,rank() over (partition by tablespace_name order by blocks desc) RANK from dba_segments ) where tablespace_name in (select tablespace_name from dba_tablespaces where contents = 'PERMANENT') and blocks > &minblocks and rank <= &topn;