Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Wed, 07 Nov 2007 @ 21:50:18 GMT


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


Subj:   Re: Calculate Percentages for a column
 
From:   Curley, David

Depending on table size and indexes, you might also try this:

     select office, office_total, office_total/sum(office_total) over ()
     pct_of_all_offices
     from (
     select office, sum(hours) office_total
     from table
     group by 1) x

This only requires one pass through the table. Just watch out that you don't end up trying to divide integers....

Dave Curley



     
  <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