Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: tricky sql report...

RE: tricky sql report...

From: Lex de Haan <lex.de.haan_at_naturaljoin.nl>
Date: Sat, 5 Feb 2005 13:26:30 +0100
Message-Id: <20050205122631.26782AA5F69@ha-smtp0.tiscali.nl>


You might start thinking along these lines: SQL> select month

  2  ,      sum(decode(...)) as DB1
  3  ,      sum(decode(...)) as DB2
  4  ,      sum(decode(...)) as DB3
  5  ,      sum(...)         as COMBINED
  6 from db_space
  7 group by month;

This only works if the list of databases is indeed hard-coded. Hope this helps, kind regards,

Lex.  



Tom Kyte Seminar: http://www.naturaljoin.nl/events/seminars.html

-----Original Message-----

From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Bob Metelsky
Sent: Saturday, February 05, 2005 12:57
To: oracle-l_at_freelists.org
Subject: tricky sql report...

All, Im doing an inventory report to provide monthly summaries of space being used by databases in the envioriments. I have a reporting table with the following columns

MONTH, SCHEMA , SPACE_USED, SPACE_FREE This table will be populated by a sql script ran against a hard coded list of databases 1x per month

the rub is Id like the report to look like this

        DB1, DB2, DB3, COMBINED
JAN 22 ,10,20, 52
FEB 1, 2, 3, 6
MAR 1, 1, 1, 3 The sql to populate the reporting table

create table DB_SPACE

	(MONTH date,
	SCHEMA varchar(10),
	USED_MB varchar(16),
	FREE_SPACE_MB varchar(16))

/

insert into DB_SPACE

SELECT 	sysdate MONTH,
        SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA', 8) SCHEMA,
	((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024,0))
USED_MB,
	NVL (SUM (dfs.bytes) / 1024 / 1024, 0) FREE_SPACE_MB
  	FROM v$datafile df, dba_free_space dfs
  	WHERE df.file# = dfs.file_id(+)
	GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes;

I know this can be done but havent had success goggling for this sort of query

Thanks!
bob

--

"Oracle error messages being what they are, do not highlight the correct cause of fault, but will identify some other error located close to where the real fault lies."

--

http://www.freelists.org/webpage/oracle-l

--

http://www.freelists.org/webpage/oracle-l Received on Sat Feb 05 2005 - 07:29:11 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US