Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 30 Apr 2008 @ 17:49:44 GMT


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


Subj:   Re: Retrieving the Second Highest Amount
 
From:   Michael Larkins

Hello Magan:

You had the right idea with the OLAP tools and the QUALIFY can go into a view:

     replace view sql00.rank_cnt as
     sel * from customer
     qualify rank() over (partition by customer order by amount desc) =
         case when count(*) over (partition by customer) > 1 then 2 else 1 end

Hope this helps,

Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor



     
  <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