Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Sat, 26 Nov 2011 @ 09:05:28 GMT


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


Subj:   Re: Sum of distinct counts from three different tables
 
From:   ramu.n

Hi,

you can try below query for best count....

     SEL (CNT_A + CNT_B + CNT_C) AS TOTAL_CNT FROM (
       SELECT COUNT(*) AS CNT_A
       FROM
        (SELECT pi_col1,pi_col2,...
         from Table_a
         group by 1,2...
        )
     )A
     CROSS JOIN
     (
       SELECT COUNT(*) AS CNT_B
       FROM
        (SELECT pi_col1,pi_col2,...
         from Table_B
         group by 1,2...
        )
     )B
     CROSS JOIN
     (
       SELECT COUNT(*) AS CNT_C
       FROM
        (SELECT pi_col1,pi_col2,...
         from Table_C
         group by 1,2...
        )
     )C

Regards,

Ram



     
  <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: 15 Jun 2023