Quantcast
Viewing all articles
Browse latest Browse all 14773

Cross tab - Pivot - response (3) by elvicio

Hi Dieter,
I have a few TD tables that I needed to do rowcounts.  e.g.
        count(*) from TableName.
Now, the result of the count is going to a temp table.  Once I get all the counts inserted into the temp table (temptable) then I need to convert those rows to column.  Just like using pivot in SQL server.
The way I accomplished this task was using the following syntax:
Select
Max(Case when t2.tablename in('table1') then rowsnum else null end) table1
,Max(Case when t2.tablename in('table2') then rowsnum else null end) table2
,Max(Case when t2.tablename in('table3') then rowsnum else null end) table3
from
(select tablename as tablename, rowsnum, row_number() over(order by tablename) as RowNr from temptable)
t2
Now, the result of this query get inserted into another permanent table that i can use to compare the counts. 
Now my table read:
databaseName   table1   table2    table3
Raymond               100       200      300
Raymon2               100       200      300
 
See, the counts match. 
In the event that the count doesn't match, i get notification.  This process it to load a production table from dev.
 
Thankx,
Raymond V.
 
 
 
 
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles