select df.tablespace_name, df.mb, df.mb-nvl(fs.freemb,0) usedmb, (df.mb-nvl(fs.freemb,0))/greatest(df.mb,df.maxmb)*100 pctused, df.maxmb
  from (select tablespace_name, sum(bytes)/1024/1024 mb, sum(maxbytes)/1024/1024 maxmb
          from dba_data_files group by tablespace_name
        union select tablespace_name, sum(bytes)/1024/1024 mb, sum(greatest(maxbytes,bytes))/1024/1024 maxmb
          from dba_temp_files group by tablespace_name) df,
       (select tablespace_name, sum(bytes)/1024/1024 freemb
          from dba_free_space group by tablespace_name) fs
 where df.tablespace_name = fs.tablespace_name(+)
order by pctused
/
