Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 03 Jun 2009 @ 09:15:27 GMT


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


Subj:   Re: LAST row in an aggregate group
 
From:   David Pracy

Chaim

This may give you an idea of how to approach your problem


regards

david pracy


     ct
     djp.test_table ( name char(20), department char(20)) insert into djp.test_table values
     ('John','IT'); insert into djp.test_table values ('Steven','IT'); insert into
     djp.test_table values ('Susan','IT'); insert into djp.test_table values ('Paul','HR');
     insert into djp.test_table values ('Pauline','HR'); sel
     * from djp.test_table;
     Sel
     * from ( Sel department
     ,
     name
     ,
     ROW_NUMBER() OVER (PARTITION BY department ORDER BY name desc) rank_asc from
     djp.test_table )DT_1 where rank_asc = 1; /
     /* Obviously I would be expecting to order by something more meaningful then a name eg a
     hire date etc */
     /*

     Name Department
     John IT
     Steven IT
     Susan IT
     Paul HR
     Pauline HR

     Would provide the following two rows

     Susan IT
     Pauline HR*/


     
  <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