Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 06 Jun 2001 @ 16:47:30 GMT


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


Subj:   Re: Query conundrum
 
From:   Fred Pluebell

You have to explicitly do (at least) two passes of the table and combine the results. The following isn't necessarily the most efficient choice but illustrates the idea:

SELECT A.col1, A.col2, B.col3, A.col4, A.col5, A.col6
FROM
 (SELECT
  column_name_1,
  count(DISTINCT column_name_2),
  sum(column_name_4),
  sum(column_name_5),
  sum(column_name_6)
 FROM
  table_name
 GROUP BY
  1 ) AS A(col1, col2, col4, col5, col6)
JOIN
 (SELECT
  column_name_1,
  count(DISTINCT column_name_3)
 FROM
  table_name
 GROUP BY
  1 ) AS B(col1, col3)
ON A.col1 = B.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: 15 Jun 2023