Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 28 Apr 2004 @ 15:14:17 GMT


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


Subj:   Re: Conditional max
 
From:   Maxwell, Donald

Consider your original data. The OLAP SUM function partitions by PARENT and sorts the data within each partition by AMT desc, CHILD desc. eg. your sorted data (with the computed OLAP SUM value for each row)

     PARENT    CHILD          AMT    OLAP_SUM
     X          C             NULL              1
     X          B             NULL              2
     X          A             NULL              3
     Y          G             40.00             1
     Y          F             25.00              2
     Y          H             NULL              3

The OLAP_SUM column is the cumulative sum(1) over the sorted data within the partition, ie a running one-up counter of the sorted rows. The QUALIFY clause behaves like a HAVING clause in that it filters rows from the result set.


Hope that helps explain.

Donald Maxwell



     
  <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