Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 15 Aug 2006 @ 18:20:52 GMT


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


Subj:   Re: Max And Count without Group by
 
From:   Victor Sokovin

Oops ... Just after I sent my reply I noticed that in the Subject line you wanted to avoid the GROUP BY. My solution will not work.

Just out of interest: why this restriction?

The formal alternative (I call it formal because although it does not use GROUP BY I doubt it is a practical alternative to the GROUP BY) is to use the window versions of MAX and COUNT.

     sel COL_A as Product, COUNT(COL_B) OVER(PARTITION BY COL_A ROWS BETWEEN
     UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as Total from the_table

and then perhaps apply the same trick you used with the MAX.

If you have a special reason to do this, of course.


Victor



     
  <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