Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 21 Sep 2004 @ 23:07:10 GMT


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


Subj:   Re: Rank() and Partition By with Large Tables
 
From:   Michael Larkins

Hi Remo:

You are close, but mixing and matching old with new formats. You are doing aggregation with OLAP - not compatible and you are mixing the GROUP BY of the Teradata extension functions with the PARTITION BY of the newer ANSI functions. Your query should probably be something like this:

     Select
      Field1
      ,Field2
      ,Rank() OVER (Partition by Field1 Order By Total_usage Desc) Ranked
     FROM (sel Field1, field2, Sum(Usage) as total_usage
                FROM   GROUP BY 1,2)
     QUALIFY Ranked < 11

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