SELECT A.*, MAX_PERM - CURRENT_PERM
FROM
(
SELECT
DATABASENAME,CAST(SUM(MAXPERM)/(1024*1024*1024) AS DECIMAL(7,2)) MAX_PERM,
CAST(SUM(CURRENTPERM)/(1024*1024*1024) AS DECIMAL(7,2)) CURRENT_PERM,
CAST(SUM(MAXSPOOL)/(1024*1024*1024) AS DECIMAL(7,2)) MAX_SPOOL,
CAST(SUM(CURRENTSPOOL)/(1024*1024*1024) AS DECIMAL(7,2)) CURRENT_SPOOL
FROM DBC.DISKSPACE
WHERE DATABASENAME LIKE '%YOUR_DB_NAME%'
GROUP BY DATABASENAME
) AS A
;
FROM
(
SELECT
DATABASENAME,CAST(SUM(MAXPERM)/(1024*1024*1024) AS DECIMAL(7,2)) MAX_PERM,
CAST(SUM(CURRENTPERM)/(1024*1024*1024) AS DECIMAL(7,2)) CURRENT_PERM,
CAST(SUM(MAXSPOOL)/(1024*1024*1024) AS DECIMAL(7,2)) MAX_SPOOL,
CAST(SUM(CURRENTSPOOL)/(1024*1024*1024) AS DECIMAL(7,2)) CURRENT_SPOOL
FROM DBC.DISKSPACE
WHERE DATABASENAME LIKE '%YOUR_DB_NAME%'
GROUP BY DATABASENAME
) AS A
;