Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 06 Jun 2001 @ 21:45:36 GMT


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


Subj:   Re: Query conundrum
 
From:   Cornelius Meade

Thanks to all that offered ideas on how to solve today's puzzle. The solution that seemed to offer the best performance and flexibility in our case involved using derived tables along the lines of the following:

SELECT A.col1,
       sum(A.col2),
       sum(A.col2),
       sum(B.col3),
       sum(A.col4),
       sum(A.col5),
       sum(A.col6)
  FROM
   (SELECT column_name_1 col1,
           count(DISTINCT column_name_2) col2,
           sum(column_name_4) col4,
           sum(column_name_5) col5,
           sum(column_name_6) col6
      FROM table_name GROUP BY column_name_1) A,
   (SELECT column_name_1 col1,
           count(DISTINCT column_name_3) col3
      FROM table_name GROUP BY column_name_1) B
WHERE A.col1 = B.col1
GROUP BY A.col1 ;
;


     
  <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: 27 Dec 2016