Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 10 Feb 2016 @ 09:36:02 GMT


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


Subj:   Re: Split Table on Rank function
 
From:   Frydryszak, Marek

You can try:

     sel grp, count(*) cnt,  min(keyval),max(keyval) from (
       sel keyval , quantile(3,keyval)  grp from tst
      ) dq
     group by 1 order by 1

or - if you want to keep the ansi standard:

     sel grp, count(*) cnt,  min(keyval),max(keyval) from (
       sel keyval , (RANK() OVER (ORDER BY keyval) - 1) * 3 / COUNT(*) OVER() grp from tst
      ) dq
     group by 1 order by 1


     
  <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