Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 01 Dec 2009 @ 20:47:03 GMT


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


Subj:   Re: Incrementing count within a group of records
 
From:   ulrich arndt

Hi David,

Dieters solution will be the fastes.

It should be also possible if you can use a derived table. Will also work if your group definition is not numeric :-)...

     select t.*.sum(week_change_id) over (order by date rows unbounded preceding and current
     row) as running_week ( select a.*, case when sum(wwtY) over (order by date rows 1
     preceding and 1 preceding) <>sum(wwtY) over (order by date rows current row and current
     row) then 1 else 0 end) as week_change_id from yourdata
     ) as t

I have no access to a db to check the syntax but I guess this should to the calculation....


Ulrich



     
  <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