SQL query to Postgres Query : select a.TABLESPACE_NAME ,a.MAXBYTES,a.MBYTES,(a.MAXBYTES-a.MBYTES),round(((a.MAXBYTES-a.MBYTES)/a.MAXBYTES)*100,2) as fieldvalues 
from
	(select TABLESPACE_NAME,sum(MAXBYTES/1024/1024) MAXBYTES,sum(BYTES/1024/1024) MBYTES from dba_data_files 
	 where TABLESPACE_NAME in (select TABLESPACE_NAME from dba_segments where owner='TEST') group by TABLESPACE_NAME) a,
	(select TABLESPACE_NAME,sum(BYTES/1024/1024) MBYTES from dba_free_space where TABLESPACE_NAME in (select TABLESPACE_NAME from dba_segments where owner='TEST') group by TABLESPACE_NAME) b 
	where a.TABLESPACE_NAME=b.TABLESPACE_NAME order by a.TABLESPACE_NAME;