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

Home -> Community -> Usenet -> c.d.o.server -> Re: wrong output from Join

Re: wrong output from Join

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Fri, 22 Jul 2005 18:18:39 +0200
Message-ID: <7s62e196mr1rcr11ge342l83ja8bvvv9uo@4ax.com>


On 22 Jul 2005 09:04:05 -0700, "Jagjeet Singh" <jagjeet_malhi_at_hotmail.com> wrote:

>Hi,
>
> I need to calculate the sum of tablespace's size and its free size.
>
>Select a.tablespace_name,sum(a.bytes) total_mb,sum(b.bytes) Free_mb
>from dba_data_files a , dba_free_space b
>where a.tablespace_name = b.tablespace_name
>group by a.tablespace_name
>/
>
>This query is givien wrong output.
>
>Can anyone is explain it why is it giving wrong output.
>
>Thanks,
>Js

One record from dba_data_files will join to all corresponding records of dba_free_space, so to all corresponding free segments.

This will work
select used.tablespace_name, used.bytes, free.bytes from
(select tablespace_name, sum(bytes) bytes  from dba_data_files
 group by tablespace_name) used,
(select tablespace_name, sum(bytes) bytes  from dba_free_space
 group by tablespace_name
) free

--
Sybrand Bakker, Senior Oracle DBA
Received on Fri Jul 22 2005 - 11:18:39 CDT

Original text of this message

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