Re: wrong output from Join
- From: Sybrand Bakker <postbus@xxxxxxxxxxxxxxxxx>
- Date: Fri, 22 Jul 2005 18:18:39 +0200
On 22 Jul 2005 09:04:05 -0700, "Jagjeet Singh"
<jagjeet_malhi@xxxxxxxxxxx> 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
.
- Follow-Ups:
- Re: wrong output from Join
- From: Jagjeet Singh
- Re: wrong output from Join
- References:
- wrong output from Join
- From: Jagjeet Singh
- wrong output from Join
- Prev by Date: wrong output from Join
- Next by Date: Re: wrong output from Join
- Previous by thread: wrong output from Join
- Next by thread: Re: wrong output from Join
- Index(es):
Relevant Pages
|