Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Thu, 09 May 2002 @ 14:08:11 GMT

  <Prev Next>   <<First <Prev Next> Last>>  

Subj:   Re: SQL to get table name with row counts?
From:   Rohit Revo


Your souutions don't achieve what I am looking for.

1st solution

Your solution will always give the count as 1 as you are grouping by dbc.tablename and each table name is unique. What I want is to see the table name and the count of rows in each table at a glance.

     (trim (databasename)||'.'||trim(tablename)) as tablename
    , count(*)
from dbc.tables
group by 1 order by 1

2nd Solution

This only gives the counts of columns in a table (from dbc.columns)and not the number of rows in a table.

select (trim (t.databasename)||'.'||trim(t.tablename)) as tablename,
count(*) from dbc.tables t join dbc.columns c on
(t.databasename = c.databasename and t.tablename = c.tablename)
group by 1 order by 1



  <Prev Next>   <<First <Prev Next> Last>>  
  Top Home Privacy Feedback  
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 28 Jun 2020