Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 13 Nov 2008 @ 10:29:57 GMT


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


Subj:   Re: Option for getting subtotals in a data column
 
From:   Sapra, Kapil Dev

Hi,

You can use SUM window function.. But this will give calculated result in extra column.

     Group total..
     SELECT col1
        , col2
        , Ncol3
        , SUM(Ncol3) OVER (PARTITION BY col1
        ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
     FROM tbl1
     ORDER BY 1,2;

For Grand total you can use..

     :
     FROM tbl1
     WITH SUM(Ncol3)
     ORDER BY 1,2;
     WITH SUM(Ncol3)

Best Regards,

Kapil Dev Sapra



     
  <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