Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

hierarchy (recursive) query - forum topic by anurag1612

$
0
0

Hi,
I have the below hirerchy -
                        D1
         D2           D3       D4
      D5  D6     D7 D8   D9 D10
 T1 T2 T3 T4  T5 T6 T7 T8 T9 T10 T11
 
My requirement is to find out currentperm of all the tables but in condition I can only give databasename is D1. Below is the query which is working at one level but not till the end.-
locking row for access
SELECT
a.DatabaseName AS DatabaseName,
a.TableName AS ObjectName,
a.tablekind AS Tablekind,
CAST (a.CreateTimeStamp AS DATE) AS Create_Date,
sum(b.currentperm)/1024/1024/1024 AS ObjectSize
FROM       dbc.TABLES a left outer join dbc.tablesize b
 on       
            a.databasename=b.databasename
            and a.tablename=b.tablename
WHERE
a.databasename in (
sel a.databasename
from dbc.databases a inner join dbc.databases b
on a.databasename=b.databasename
where a.ownername in ( 'D1')
)
group   by 1,2,3,4
order by 4 desc;

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>