Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 28 Apr 2004 @ 17:51:30 GMT


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


Subj:   Re: Conditional max
 
From:   Hough, David A

I think the solution by Donald Maxwell:

     SELECT
             ,PARENT
             ,CHILD
             ,AMT
     FROM    SomeTable
     QUALIFY SUM(1) OVER ( PARTITION BY PARENT
             ORDER BY AMT desc, CHILD desc ROWS UNBOUNDED PRECEDING ) = 1;

Can be improved somewhat by replacing SUM with RANK:

     SELECT
              PARENT
             ,CHILD
             ,AMT
     FROM    SomeTable
     QUALIFY RANK() OVER ( PARTITION BY PARENT
                           ORDER BY AMT desc, CHILD desc) = 1;

Not that I would have found his original on my own... ;)


/dave hough



     
  <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